fix(admin): issue correct password reset tokens (#27)
This commit is contained in:
parent
9fdc374443
commit
90f8132e4b
@ -24,7 +24,6 @@ import {UserFlags} from '~/Constants';
|
|||||||
import {InputValidationError, UnknownUserError} from '~/Errors';
|
import {InputValidationError, UnknownUserError} from '~/Errors';
|
||||||
import type {ICacheService} from '~/infrastructure/ICacheService';
|
import type {ICacheService} from '~/infrastructure/ICacheService';
|
||||||
import type {IEmailService} from '~/infrastructure/IEmailService';
|
import type {IEmailService} from '~/infrastructure/IEmailService';
|
||||||
import type {SnowflakeService} from '~/infrastructure/SnowflakeService';
|
|
||||||
import type {BotMfaMirrorService} from '~/oauth/BotMfaMirrorService';
|
import type {BotMfaMirrorService} from '~/oauth/BotMfaMirrorService';
|
||||||
import type {IUserRepository} from '~/user/IUserRepository';
|
import type {IUserRepository} from '~/user/IUserRepository';
|
||||||
import type {UserContactChangeLogService} from '~/user/services/UserContactChangeLogService';
|
import type {UserContactChangeLogService} from '~/user/services/UserContactChangeLogService';
|
||||||
@ -45,7 +44,6 @@ interface AdminUserSecurityServiceDeps {
|
|||||||
userRepository: IUserRepository;
|
userRepository: IUserRepository;
|
||||||
authService: AuthService;
|
authService: AuthService;
|
||||||
emailService: IEmailService;
|
emailService: IEmailService;
|
||||||
snowflakeService: SnowflakeService;
|
|
||||||
auditService: AdminAuditService;
|
auditService: AdminAuditService;
|
||||||
updatePropagator: AdminUserUpdatePropagator;
|
updatePropagator: AdminUserUpdatePropagator;
|
||||||
botMfaMirrorService?: BotMfaMirrorService;
|
botMfaMirrorService?: BotMfaMirrorService;
|
||||||
@ -136,7 +134,7 @@ export class AdminUserSecurityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async sendPasswordReset(data: SendPasswordResetRequest, adminUserId: UserID, auditLogReason: string | null) {
|
async sendPasswordReset(data: SendPasswordResetRequest, adminUserId: UserID, auditLogReason: string | null) {
|
||||||
const {userRepository, emailService, snowflakeService, auditService} = this.deps;
|
const {userRepository, emailService, authService, auditService} = this.deps;
|
||||||
const userId = createUserID(data.user_id);
|
const userId = createUserID(data.user_id);
|
||||||
const user = await userRepository.findUnique(userId);
|
const user = await userRepository.findUnique(userId);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -147,7 +145,7 @@ export class AdminUserSecurityService {
|
|||||||
throw InputValidationError.create('email', 'User does not have an email address');
|
throw InputValidationError.create('email', 'User does not have an email address');
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = createPasswordResetToken(snowflakeService.generate().toString());
|
const token = createPasswordResetToken(await authService.generateSecureToken());
|
||||||
await userRepository.createPasswordResetToken({
|
await userRepository.createPasswordResetToken({
|
||||||
token_: token,
|
token_: token,
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
|
|||||||
@ -29,7 +29,6 @@ import type {IEmailService} from '~/infrastructure/IEmailService';
|
|||||||
import type {IGatewayService} from '~/infrastructure/IGatewayService';
|
import type {IGatewayService} from '~/infrastructure/IGatewayService';
|
||||||
import type {PendingJoinInviteStore} from '~/infrastructure/PendingJoinInviteStore';
|
import type {PendingJoinInviteStore} from '~/infrastructure/PendingJoinInviteStore';
|
||||||
import type {RedisBulkMessageDeletionQueueService} from '~/infrastructure/RedisBulkMessageDeletionQueueService';
|
import type {RedisBulkMessageDeletionQueueService} from '~/infrastructure/RedisBulkMessageDeletionQueueService';
|
||||||
import type {SnowflakeService} from '~/infrastructure/SnowflakeService';
|
|
||||||
import type {UserCacheService} from '~/infrastructure/UserCacheService';
|
import type {UserCacheService} from '~/infrastructure/UserCacheService';
|
||||||
import type {InviteService} from '~/invite/InviteService';
|
import type {InviteService} from '~/invite/InviteService';
|
||||||
import type {BotMfaMirrorService} from '~/oauth/BotMfaMirrorService';
|
import type {BotMfaMirrorService} from '~/oauth/BotMfaMirrorService';
|
||||||
@ -75,7 +74,6 @@ interface AdminUserServiceDeps {
|
|||||||
userRepository: IUserRepository;
|
userRepository: IUserRepository;
|
||||||
guildRepository: IGuildRepository;
|
guildRepository: IGuildRepository;
|
||||||
discriminatorService: IDiscriminatorService;
|
discriminatorService: IDiscriminatorService;
|
||||||
snowflakeService: SnowflakeService;
|
|
||||||
authService: AuthService;
|
authService: AuthService;
|
||||||
emailService: IEmailService;
|
emailService: IEmailService;
|
||||||
entityAssetService: EntityAssetService;
|
entityAssetService: EntityAssetService;
|
||||||
@ -135,7 +133,6 @@ export class AdminUserService {
|
|||||||
userRepository: deps.userRepository,
|
userRepository: deps.userRepository,
|
||||||
authService: deps.authService,
|
authService: deps.authService,
|
||||||
emailService: deps.emailService,
|
emailService: deps.emailService,
|
||||||
snowflakeService: deps.snowflakeService,
|
|
||||||
auditService: deps.auditService,
|
auditService: deps.auditService,
|
||||||
updatePropagator: this.updatePropagator,
|
updatePropagator: this.updatePropagator,
|
||||||
botMfaMirrorService: deps.botMfaMirrorService,
|
botMfaMirrorService: deps.botMfaMirrorService,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user