MCPcopy
hub / github.com/Unleash/unleash / setPasswordHash

Method setPasswordHash

src/lib/features/users/user-store.ts:237–257  ·  view source on GitHub ↗
(
        userId: number,
        passwordHash: string,
        disallowNPreviousPasswords: number,
    )

Source from the content-addressed store, hash-verified

235 }
236
237 async setPasswordHash(
238 userId: number,
239 passwordHash: string,
240 disallowNPreviousPasswords: number,
241 ): Promise<void> {
242 await this.activeUsers().where('id', userId).update({
243 // @ts-expect-error password_hash does not exist in User type
244 password_hash: passwordHash,
245 });
246 // We apparently set this to null, but you should be allowed to have null, so need to allow this
247 if (passwordHash) {
248 await this.db(PASSWORD_HASH_TABLE).insert({
249 user_id: userId,
250 password_hash: passwordHash,
251 });
252 await this.deletePasswordsUsedMoreThanNTimesAgo(
253 userId,
254 disallowNPreviousPasswords,
255 );
256 }
257 }
258
259 async incLoginAttempts(user: User): Promise<void> {
260 await this.buildSelectUser(user).increment('login_attempts', 1);

Callers

nothing calls this directly

Calls 5

activeUsersMethod · 0.95
whereMethod · 0.80
updateMethod · 0.65
insertMethod · 0.65

Tested by

no test coverage detected