@a-type/auth
Advanced tools
Comparing version 0.4.7 to 0.4.8
@@ -200,6 +200,10 @@ import { AuthError } from './error.js'; | ||
if (user) { | ||
if (!addProvidersToExistingUsers) { | ||
if (!addProvidersToExistingUsers || user.password) { | ||
throw new AuthError('User already exists', 409); | ||
} | ||
else { | ||
await db.updateUser(user.id, { | ||
emailVerifiedAt: new Date().toISOString(), | ||
plaintextPassword: password, | ||
}); | ||
userId = user.id; | ||
@@ -206,0 +210,0 @@ } |
export interface AuthDB { | ||
insertUser(user: Omit<AuthUser, 'id'> & { | ||
insertUser(user: Omit<AuthUser, 'id' | 'password'> & { | ||
plaintextPassword: string | null; | ||
}): Promise<Pick<AuthUser, 'id'>>; | ||
updateUser(userId: string, user: Partial<Omit<AuthUser, 'id' | 'email' | 'password'> & { | ||
plaintextPassword: string | null; | ||
}>): Promise<void>; | ||
insertAccount(account: Omit<AuthAccount, 'id'>): Promise<Pick<AuthAccount, 'id'>>; | ||
@@ -20,2 +23,4 @@ getUserByEmail(email: string): Promise<AuthUser | undefined>; | ||
imageUrl: string | null; | ||
/** the hashed password, please. */ | ||
password: string | null; | ||
} | ||
@@ -22,0 +27,0 @@ export interface AuthAccount { |
{ | ||
"name": "@a-type/auth", | ||
"version": "0.4.7", | ||
"version": "0.4.8", | ||
"description": "My personal auth request handlers", | ||
@@ -5,0 +5,0 @@ "module": "dist/esm/index.js", |
export interface AuthDB { | ||
insertUser( | ||
user: Omit<AuthUser, 'id'> & { plaintextPassword: string | null }, | ||
user: Omit<AuthUser, 'id' | 'password'> & { | ||
plaintextPassword: string | null; | ||
}, | ||
): Promise<Pick<AuthUser, 'id'>>; | ||
updateUser( | ||
userId: string, | ||
user: Partial< | ||
Omit<AuthUser, 'id' | 'email' | 'password'> & { | ||
plaintextPassword: string | null; | ||
} | ||
>, | ||
): Promise<void>; | ||
insertAccount( | ||
@@ -32,2 +42,4 @@ account: Omit<AuthAccount, 'id'>, | ||
imageUrl: string | null; | ||
/** the hashed password, please. */ | ||
password: string | null; | ||
} | ||
@@ -34,0 +46,0 @@ |
@@ -287,5 +287,9 @@ import { AuthDB } from './db.js'; | ||
if (user) { | ||
if (!addProvidersToExistingUsers) { | ||
if (!addProvidersToExistingUsers || user.password) { | ||
throw new AuthError('User already exists', 409); | ||
} else { | ||
await db.updateUser(user.id, { | ||
emailVerifiedAt: new Date().toISOString(), | ||
plaintextPassword: password, | ||
}); | ||
userId = user.id; | ||
@@ -292,0 +296,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113913
2325