Better naming
This commit is contained in:
parent
6a76c4797a
commit
881e3375ab
@ -2,10 +2,10 @@ import bcrypt from 'bcryptjs'
|
|||||||
import UserRepository from '../repositories/userRepository'
|
import UserRepository from '../repositories/userRepository'
|
||||||
import PasswordResetTokenRepository from '../repositories/passwordResetTokenRepository'
|
import PasswordResetTokenRepository from '../repositories/passwordResetTokenRepository'
|
||||||
import prisma from '../utilities/prisma'
|
import prisma from '../utilities/prisma'
|
||||||
import { User, PasswordResetToken } from '@prisma/client'
|
import { User } from '@prisma/client'
|
||||||
import config from '../utilities/config'
|
import config from '../utilities/config'
|
||||||
import NodeMailer from 'nodemailer'
|
import NodeMailer from 'nodemailer'
|
||||||
import { gameLogger, httpLogger } from '../utilities/logger'
|
import { httpLogger } from '../utilities/logger'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User service
|
* User service
|
||||||
@ -75,7 +75,7 @@ class UserService {
|
|||||||
* Reset password
|
* Reset password
|
||||||
* @param email
|
* @param email
|
||||||
*/
|
*/
|
||||||
async resetPassword(email: string): Promise<boolean> {
|
async requestPasswordReset(email: string): Promise<boolean> {
|
||||||
const user = await UserRepository.getByEmail(email)
|
const user = await UserRepository.getByEmail(email)
|
||||||
if (!user) return false
|
if (!user) return false
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ class UserService {
|
|||||||
* @param urlToken
|
* @param urlToken
|
||||||
* @param password
|
* @param password
|
||||||
*/
|
*/
|
||||||
async newPassword(urlToken: string, password: string): Promise<boolean | User> {
|
async resetPassword(urlToken: string, password: string): Promise<boolean | User> {
|
||||||
try {
|
try {
|
||||||
const tokenData = await PasswordResetTokenRepository.getByToken(urlToken)
|
const tokenData = await PasswordResetTokenRepository.getByToken(urlToken)
|
||||||
if (!tokenData) {
|
if (!tokenData) {
|
||||||
|
@ -76,7 +76,7 @@ async function addHttpRoutes(app: Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userService = new UserService()
|
const userService = new UserService()
|
||||||
const sentEmail = await userService.resetPassword(email)
|
const sentEmail = await userService.requestPasswordReset(email)
|
||||||
|
|
||||||
if (sentEmail) {
|
if (sentEmail) {
|
||||||
return res.status(200).json({ message: 'Email has been sent' })
|
return res.status(200).json({ message: 'Email has been sent' })
|
||||||
@ -100,7 +100,7 @@ async function addHttpRoutes(app: Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userService = new UserService()
|
const userService = new UserService()
|
||||||
const resetPassword = await userService.newPassword(urlToken, password)
|
const resetPassword = await userService.resetPassword(urlToken, password)
|
||||||
|
|
||||||
if (resetPassword) {
|
if (resetPassword) {
|
||||||
return res.status(200).json({ message: 'Password has been reset' })
|
return res.status(200).json({ message: 'Password has been reset' })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user