mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 03:26:47 +08:00
refactor(server): auth (#5895)
Remove `next-auth` and implement our own Authorization/Authentication system from scratch.
## Server
- [x] tokens
- [x] function
- [x] encryption
- [x] AuthController
- [x] /api/auth/sign-in
- [x] /api/auth/sign-out
- [x] /api/auth/session
- [x] /api/auth/session (WE SUPPORT MULTI-ACCOUNT!)
- [x] OAuthPlugin
- [x] OAuthController
- [x] /oauth/login
- [x] /oauth/callback
- [x] Providers
- [x] Google
- [x] GitHub
## Client
- [x] useSession
- [x] cloudSignIn
- [x] cloudSignOut
## NOTE:
Tests will be adding in the future
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
mutation changeEmail($token: String!) {
|
||||
changeEmail(token: $token) {
|
||||
mutation changeEmail($token: String!, $email: String!) {
|
||||
changeEmail(token: $token, email: $email) {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
email
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
mutation changePassword($token: String!, $newPassword: String!) {
|
||||
changePassword(token: $token, newPassword: $newPassword) {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
email
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ query earlyAccessUsers {
|
||||
email
|
||||
avatarUrl
|
||||
emailVerified
|
||||
createdAt
|
||||
subscription {
|
||||
plan
|
||||
recurring
|
||||
|
||||
@@ -5,7 +5,6 @@ query getCurrentUser {
|
||||
email
|
||||
emailVerified
|
||||
avatarUrl
|
||||
createdAt
|
||||
token {
|
||||
sessionToken
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
query oauthProviders {
|
||||
serverConfig {
|
||||
oauthProviders
|
||||
}
|
||||
}
|
||||
@@ -101,11 +101,9 @@ export const changeEmailMutation = {
|
||||
definitionName: 'changeEmail',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation changeEmail($token: String!) {
|
||||
changeEmail(token: $token) {
|
||||
mutation changeEmail($token: String!, $email: String!) {
|
||||
changeEmail(token: $token, email: $email) {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
email
|
||||
}
|
||||
}`,
|
||||
@@ -120,9 +118,6 @@ export const changePasswordMutation = {
|
||||
mutation changePassword($token: String!, $newPassword: String!) {
|
||||
changePassword(token: $token, newPassword: $newPassword) {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
email
|
||||
}
|
||||
}`,
|
||||
};
|
||||
@@ -212,7 +207,6 @@ query earlyAccessUsers {
|
||||
email
|
||||
avatarUrl
|
||||
emailVerified
|
||||
createdAt
|
||||
subscription {
|
||||
plan
|
||||
recurring
|
||||
@@ -248,7 +242,6 @@ query getCurrentUser {
|
||||
email
|
||||
emailVerified
|
||||
avatarUrl
|
||||
createdAt
|
||||
token {
|
||||
sessionToken
|
||||
}
|
||||
@@ -324,6 +317,19 @@ query getMembersByWorkspaceId($workspaceId: String!, $skip: Int!, $take: Int!) {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const oauthProvidersQuery = {
|
||||
id: 'oauthProvidersQuery' as const,
|
||||
operationName: 'oauthProviders',
|
||||
definitionName: 'serverConfig',
|
||||
containsFile: false,
|
||||
query: `
|
||||
query oauthProviders {
|
||||
serverConfig {
|
||||
oauthProviders
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const getPublicWorkspaceQuery = {
|
||||
id: 'getPublicWorkspaceQuery' as const,
|
||||
operationName: 'getPublicWorkspace',
|
||||
@@ -627,8 +633,8 @@ export const sendChangeEmailMutation = {
|
||||
definitionName: 'sendChangeEmail',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation sendChangeEmail($email: String!, $callbackUrl: String!) {
|
||||
sendChangeEmail(email: $email, callbackUrl: $callbackUrl)
|
||||
mutation sendChangeEmail($callbackUrl: String!) {
|
||||
sendChangeEmail(callbackUrl: $callbackUrl)
|
||||
}`,
|
||||
};
|
||||
|
||||
@@ -638,8 +644,8 @@ export const sendChangePasswordEmailMutation = {
|
||||
definitionName: 'sendChangePasswordEmail',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation sendChangePasswordEmail($email: String!, $callbackUrl: String!) {
|
||||
sendChangePasswordEmail(email: $email, callbackUrl: $callbackUrl)
|
||||
mutation sendChangePasswordEmail($callbackUrl: String!) {
|
||||
sendChangePasswordEmail(callbackUrl: $callbackUrl)
|
||||
}`,
|
||||
};
|
||||
|
||||
@@ -649,8 +655,8 @@ export const sendSetPasswordEmailMutation = {
|
||||
definitionName: 'sendSetPasswordEmail',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation sendSetPasswordEmail($email: String!, $callbackUrl: String!) {
|
||||
sendSetPasswordEmail(email: $email, callbackUrl: $callbackUrl)
|
||||
mutation sendSetPasswordEmail($callbackUrl: String!) {
|
||||
sendSetPasswordEmail(callbackUrl: $callbackUrl)
|
||||
}`,
|
||||
};
|
||||
|
||||
@@ -665,6 +671,17 @@ mutation sendVerifyChangeEmail($token: String!, $email: String!, $callbackUrl: S
|
||||
}`,
|
||||
};
|
||||
|
||||
export const sendVerifyEmailMutation = {
|
||||
id: 'sendVerifyEmailMutation' as const,
|
||||
operationName: 'sendVerifyEmail',
|
||||
definitionName: 'sendVerifyEmail',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation sendVerifyEmail($callbackUrl: String!) {
|
||||
sendVerifyEmail(callbackUrl: $callbackUrl)
|
||||
}`,
|
||||
};
|
||||
|
||||
export const serverConfigQuery = {
|
||||
id: 'serverConfigQuery' as const,
|
||||
operationName: 'serverConfig',
|
||||
@@ -695,36 +712,6 @@ mutation setWorkspacePublicById($id: ID!, $public: Boolean!) {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const signInMutation = {
|
||||
id: 'signInMutation' as const,
|
||||
operationName: 'signIn',
|
||||
definitionName: 'signIn',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation signIn($email: String!, $password: String!) {
|
||||
signIn(email: $email, password: $password) {
|
||||
token {
|
||||
token
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const signUpMutation = {
|
||||
id: 'signUpMutation' as const,
|
||||
operationName: 'signUp',
|
||||
definitionName: 'signUp',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation signUp($name: String!, $email: String!, $password: String!) {
|
||||
signUp(name: $name, email: $email, password: $password) {
|
||||
token {
|
||||
token
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const subscriptionQuery = {
|
||||
id: 'subscriptionQuery' as const,
|
||||
operationName: 'subscription',
|
||||
@@ -766,6 +753,20 @@ mutation updateSubscription($recurring: SubscriptionRecurring!, $idempotencyKey:
|
||||
}`,
|
||||
};
|
||||
|
||||
export const updateUserProfileMutation = {
|
||||
id: 'updateUserProfileMutation' as const,
|
||||
operationName: 'updateUserProfile',
|
||||
definitionName: 'updateProfile',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation updateUserProfile($input: UpdateUserInput!) {
|
||||
updateProfile(input: $input) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const uploadAvatarMutation = {
|
||||
id: 'uploadAvatarMutation' as const,
|
||||
operationName: 'uploadAvatar',
|
||||
@@ -782,6 +783,17 @@ mutation uploadAvatar($avatar: Upload!) {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const verifyEmailMutation = {
|
||||
id: 'verifyEmailMutation' as const,
|
||||
operationName: 'verifyEmail',
|
||||
definitionName: 'verifyEmail',
|
||||
containsFile: false,
|
||||
query: `
|
||||
mutation verifyEmail($token: String!) {
|
||||
verifyEmail(token: $token)
|
||||
}`,
|
||||
};
|
||||
|
||||
export const enabledFeaturesQuery = {
|
||||
id: 'enabledFeaturesQuery' as const,
|
||||
operationName: 'enabledFeatures',
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
mutation sendChangeEmail($email: String!, $callbackUrl: String!) {
|
||||
sendChangeEmail(email: $email, callbackUrl: $callbackUrl)
|
||||
mutation sendChangeEmail($callbackUrl: String!) {
|
||||
sendChangeEmail(callbackUrl: $callbackUrl)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
mutation sendChangePasswordEmail($email: String!, $callbackUrl: String!) {
|
||||
sendChangePasswordEmail(email: $email, callbackUrl: $callbackUrl)
|
||||
mutation sendChangePasswordEmail($callbackUrl: String!) {
|
||||
sendChangePasswordEmail(callbackUrl: $callbackUrl)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
mutation sendSetPasswordEmail($email: String!, $callbackUrl: String!) {
|
||||
sendSetPasswordEmail(email: $email, callbackUrl: $callbackUrl)
|
||||
mutation sendSetPasswordEmail($callbackUrl: String!) {
|
||||
sendSetPasswordEmail(callbackUrl: $callbackUrl)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
mutation sendVerifyEmail($callbackUrl: String!) {
|
||||
sendVerifyEmail(callbackUrl: $callbackUrl)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
mutation signIn($email: String!, $password: String!) {
|
||||
signIn(email: $email, password: $password) {
|
||||
token {
|
||||
token
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
mutation signUp($name: String!, $email: String!, $password: String!) {
|
||||
signUp(name: $name, email: $email, password: $password) {
|
||||
token {
|
||||
token
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
mutation updateUserProfile($input: UpdateUserInput!) {
|
||||
updateProfile(input: $input) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
mutation verifyEmail($token: String!) {
|
||||
verifyEmail(token: $token)
|
||||
}
|
||||
Reference in New Issue
Block a user