@accounts/password
Advanced tools
Comparing version 0.26.0-alpha.2 to 0.26.0-alpha.3
@@ -92,3 +92,3 @@ import { User, TokenRecord, DatabaseInterface, AuthenticationService, ConnectionInformations, LoginResult, CreateUserServicePassword, LoginUserPasswordService } from '@accounts/types'; | ||
} | ||
export default class AccountsPassword implements AuthenticationService { | ||
export default class AccountsPassword<CustomUser extends User = User> implements AuthenticationService { | ||
serviceName: string; | ||
@@ -100,4 +100,4 @@ server: AccountsServer; | ||
constructor(options?: AccountsPasswordOptions); | ||
setStore(store: DatabaseInterface): void; | ||
authenticate(params: LoginUserPasswordService): Promise<User>; | ||
setStore(store: DatabaseInterface<CustomUser>): void; | ||
authenticate(params: LoginUserPasswordService): Promise<CustomUser>; | ||
/** | ||
@@ -108,3 +108,3 @@ * @description Find a user by one of his emails. | ||
*/ | ||
findUserByEmail(email: string): Promise<User | null>; | ||
findUserByEmail(email: string): Promise<CustomUser | null>; | ||
/** | ||
@@ -115,3 +115,3 @@ * @description Find a user by his username. | ||
*/ | ||
findUserByUsername(username: string): Promise<User | null>; | ||
findUserByUsername(username: string): Promise<CustomUser | null>; | ||
/** | ||
@@ -118,0 +118,0 @@ * @description Add an email address for a user. |
{ | ||
"name": "@accounts/password", | ||
"version": "0.26.0-alpha.2", | ||
"version": "0.26.0-alpha.3", | ||
"license": "MIT", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@accounts/two-factor": "^0.26.0-alpha.2", | ||
"@accounts/two-factor": "^0.26.0-alpha.3", | ||
"bcryptjs": "^2.4.3", | ||
@@ -28,4 +28,4 @@ "lodash": "^4.17.15", | ||
"devDependencies": { | ||
"@accounts/server": "^0.26.0-alpha.2", | ||
"@accounts/types": "^0.26.0-alpha.2", | ||
"@accounts/server": "^0.26.0-alpha.3", | ||
"@accounts/types": "^0.26.0-alpha.3", | ||
"@types/bcryptjs": "2.4.2", | ||
@@ -41,3 +41,3 @@ "@types/jest": "25.1.4", | ||
}, | ||
"gitHead": "ad0914817551b832a11600613981ae5dba11c09d" | ||
"gitHead": "c117b8980f2153d497be744f1280bb2db2470514" | ||
} |
@@ -162,3 +162,4 @@ import { trim, isEmpty, pick, isString, isPlainObject, find, includes, defer } from 'lodash'; | ||
export default class AccountsPassword implements AuthenticationService { | ||
export default class AccountsPassword<CustomUser extends User = User> | ||
implements AuthenticationService { | ||
public serviceName = 'password'; | ||
@@ -168,3 +169,3 @@ public server!: AccountsServer; | ||
private options: AccountsPasswordOptions & typeof defaultOptions; | ||
private db!: DatabaseInterface; | ||
private db!: DatabaseInterface<CustomUser>; | ||
@@ -176,3 +177,3 @@ constructor(options: AccountsPasswordOptions = {}) { | ||
public setStore(store: DatabaseInterface) { | ||
public setStore(store: DatabaseInterface<CustomUser>) { | ||
this.db = store; | ||
@@ -182,3 +183,3 @@ this.twoFactor.setStore(store); | ||
public async authenticate(params: LoginUserPasswordService): Promise<User> { | ||
public async authenticate(params: LoginUserPasswordService): Promise<CustomUser> { | ||
const { user, password, code } = params; | ||
@@ -210,3 +211,3 @@ if (!user || !password) { | ||
*/ | ||
public findUserByEmail(email: string): Promise<User | null> { | ||
public findUserByEmail(email: string): Promise<CustomUser | null> { | ||
return this.db.findUserByEmail(email); | ||
@@ -220,3 +221,3 @@ } | ||
*/ | ||
public findUserByUsername(username: string): Promise<User | null> { | ||
public findUserByUsername(username: string): Promise<CustomUser | null> { | ||
return this.db.findUserByUsername(username); | ||
@@ -675,3 +676,3 @@ } | ||
password: string | ||
): Promise<User> { | ||
): Promise<CustomUser> { | ||
const { username, email, id } = isString(user) | ||
@@ -681,3 +682,3 @@ ? this.toUsernameAndEmail({ user }) | ||
let foundUser: User | null = null; | ||
let foundUser: CustomUser | null = null; | ||
@@ -684,0 +685,0 @@ if (id) { |
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
382854
3604