@accounts/password
Advanced tools
Comparing version 1.0.0-alpha-20231120163547-4a461fcc to 1.0.0-alpha-20231120164530-e14d6a81
@@ -5,4 +5,4 @@ import { type Injector } from 'graphql-modules'; | ||
export declare const infosMiddleware: (req: Request, _res: Response, next: NextFunction) => void; | ||
export declare const verifyEmail: (import("express-validator").ValidationChain | ((accountsPasswordOrInjector: Injector | AccountsPassword) => (req: Request, res: Response) => Promise<void>))[]; | ||
export declare const resetPassword: (import("express-validator").ValidationChain | ((accountsPasswordOrInjector: Injector | AccountsPassword) => (req: Request, res: Response) => Promise<void>))[]; | ||
export declare const verifyEmail: (accountsPasswordOrInjector: Injector | AccountsPassword) => (import("express-validator").ValidationChain | ((req: Request, res: Response) => Promise<void>))[]; | ||
export declare const resetPassword: (accountsPasswordOrInjector: Injector | AccountsPassword) => (import("express-validator").ValidationChain | ((req: Request, res: Response) => Promise<void>))[]; | ||
export declare const resetPasswordForm: (import("express-validator").ValidationChain | ((req: Request, res: Response) => void))[]; |
@@ -39,5 +39,5 @@ "use strict"; | ||
exports.infosMiddleware = infosMiddleware; | ||
exports.verifyEmail = [ | ||
const verifyEmail = (accountsPasswordOrInjector) => [ | ||
(0, express_validator_1.param)('token').isString().notEmpty(), | ||
(accountsPasswordOrInjector) => async (req, res) => { | ||
async (req, res) => { | ||
try { | ||
@@ -50,4 +50,4 @@ const { token } = matchOrThrow(req); | ||
res.send(getHtml('Email successfully verified', ` | ||
<h3>The email address has been successfully verified.</h3> | ||
`)); | ||
<h3>The email address has been successfully verified.</h3> | ||
`)); | ||
} | ||
@@ -58,11 +58,12 @@ catch (err) { | ||
getHtml('Email verification error', ` | ||
<h3>The email address couldn't be verified: ${err.message ?? 'unknown error'}</h3> | ||
`)); | ||
<h3>The email address couldn't be verified: ${err.message ?? 'unknown error'}</h3> | ||
`)); | ||
} | ||
}, | ||
]; | ||
exports.resetPassword = [ | ||
exports.verifyEmail = verifyEmail; | ||
const resetPassword = (accountsPasswordOrInjector) => [ | ||
(0, express_validator_1.body)('token').isString().notEmpty(), | ||
(0, express_validator_1.body)('newPassword').isString().notEmpty(), | ||
(accountsPasswordOrInjector) => async (req, res) => { | ||
async (req, res) => { | ||
try { | ||
@@ -75,4 +76,4 @@ const { token, newPassword } = matchOrThrow(req); | ||
res.send(getHtml('Password successfully changed', ` | ||
<h3>The password has been successfully changed.</h3> | ||
`)); | ||
<h3>The password has been successfully changed.</h3> | ||
`)); | ||
} | ||
@@ -82,7 +83,8 @@ catch (err) { | ||
res.send(getHtml('Password reset error', ` | ||
<h3>The password couldn't be changed: ${err.message ?? 'unknown error'}</h3> | ||
`)); | ||
<h3>The password couldn't be changed: ${err.message ?? 'unknown error'}</h3> | ||
`)); | ||
} | ||
}, | ||
]; | ||
exports.resetPassword = resetPassword; | ||
exports.resetPasswordForm = [ | ||
@@ -89,0 +91,0 @@ (0, express_validator_1.param)('token').isString().notEmpty().escape(), |
{ | ||
"name": "@accounts/password", | ||
"version": "1.0.0-alpha-20231120163547-4a461fcc", | ||
"version": "1.0.0-alpha-20231120164530-e14d6a81", | ||
"license": "MIT", | ||
@@ -25,3 +25,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@accounts/two-factor": "1.0.0-alpha-20231120163547-4a461fcc", | ||
"@accounts/two-factor": "1.0.0-alpha-20231120164530-e14d6a81", | ||
"bcryptjs": "2.4.3", | ||
@@ -32,4 +32,4 @@ "express-validator": "^7.0.1", | ||
"devDependencies": { | ||
"@accounts/server": "1.0.0-alpha-20231120163547-4a461fcc", | ||
"@accounts/types": "1.0.0-alpha-20231120163547-4a461fcc", | ||
"@accounts/server": "1.0.0-alpha-20231120164530-e14d6a81", | ||
"@accounts/types": "1.0.0-alpha-20231120164530-e14d6a81", | ||
"@types/bcryptjs": "2.4.6", | ||
@@ -44,3 +44,3 @@ "@types/express": "^4.17.21", | ||
"peerDependencies": { | ||
"@accounts/server": "1.0.0-alpha-20231120163547-4a461fcc", | ||
"@accounts/server": "1.0.0-alpha-20231120164530-e14d6a81", | ||
"graphql": "^16.0.0", | ||
@@ -47,0 +47,0 @@ "graphql-modules": "^3.0.0" |
@@ -42,67 +42,65 @@ import { type Injector } from 'graphql-modules'; | ||
export const verifyEmail = [ | ||
export const verifyEmail = (accountsPasswordOrInjector: Injector | AccountsPassword) => [ | ||
param('token').isString().notEmpty(), | ||
(accountsPasswordOrInjector: Injector | AccountsPassword) => | ||
async (req: Request, res: Response) => { | ||
try { | ||
const { token } = matchOrThrow<{ token: string }>(req); | ||
const accountsPassword = | ||
accountsPasswordOrInjector instanceof AccountsPassword | ||
? accountsPasswordOrInjector | ||
: accountsPasswordOrInjector.get(AccountsPassword); | ||
await accountsPassword.verifyEmail(token); | ||
res.send( | ||
getHtml( | ||
'Email successfully verified', | ||
` | ||
<h3>The email address has been successfully verified.</h3> | ||
` | ||
) | ||
); | ||
} catch (err: any) { | ||
res.send( | ||
//codeql[js/xss-through-exception] | ||
getHtml( | ||
'Email verification error', | ||
` | ||
<h3>The email address couldn't be verified: ${err.message ?? 'unknown error'}</h3> | ||
` | ||
) | ||
); | ||
} | ||
}, | ||
async (req: Request, res: Response) => { | ||
try { | ||
const { token } = matchOrThrow<{ token: string }>(req); | ||
const accountsPassword = | ||
accountsPasswordOrInjector instanceof AccountsPassword | ||
? accountsPasswordOrInjector | ||
: accountsPasswordOrInjector.get(AccountsPassword); | ||
await accountsPassword.verifyEmail(token); | ||
res.send( | ||
getHtml( | ||
'Email successfully verified', | ||
` | ||
<h3>The email address has been successfully verified.</h3> | ||
` | ||
) | ||
); | ||
} catch (err: any) { | ||
res.send( | ||
//codeql[js/xss-through-exception] | ||
getHtml( | ||
'Email verification error', | ||
` | ||
<h3>The email address couldn't be verified: ${err.message ?? 'unknown error'}</h3> | ||
` | ||
) | ||
); | ||
} | ||
}, | ||
]; | ||
export const resetPassword = [ | ||
export const resetPassword = (accountsPasswordOrInjector: Injector | AccountsPassword) => [ | ||
body('token').isString().notEmpty(), | ||
body('newPassword').isString().notEmpty(), | ||
(accountsPasswordOrInjector: Injector | AccountsPassword) => | ||
async (req: Request, res: Response) => { | ||
try { | ||
const { token, newPassword } = matchOrThrow<{ token: string; newPassword: string }>(req); | ||
const accountsPassword = | ||
accountsPasswordOrInjector instanceof AccountsPassword | ||
? accountsPasswordOrInjector | ||
: accountsPasswordOrInjector.get(AccountsPassword); | ||
await accountsPassword.resetPassword(token, newPassword, req.infos); | ||
res.send( | ||
getHtml( | ||
'Password successfully changed', | ||
` | ||
<h3>The password has been successfully changed.</h3> | ||
` | ||
) | ||
); | ||
} catch (err: any) { | ||
//codeql[js/xss-through-exception] | ||
res.send( | ||
getHtml( | ||
'Password reset error', | ||
` | ||
<h3>The password couldn't be changed: ${err.message ?? 'unknown error'}</h3> | ||
` | ||
) | ||
); | ||
} | ||
}, | ||
async (req: Request, res: Response) => { | ||
try { | ||
const { token, newPassword } = matchOrThrow<{ token: string; newPassword: string }>(req); | ||
const accountsPassword = | ||
accountsPasswordOrInjector instanceof AccountsPassword | ||
? accountsPasswordOrInjector | ||
: accountsPasswordOrInjector.get(AccountsPassword); | ||
await accountsPassword.resetPassword(token, newPassword, req.infos); | ||
res.send( | ||
getHtml( | ||
'Password successfully changed', | ||
` | ||
<h3>The password has been successfully changed.</h3> | ||
` | ||
) | ||
); | ||
} catch (err: any) { | ||
//codeql[js/xss-through-exception] | ||
res.send( | ||
getHtml( | ||
'Password reset error', | ||
` | ||
<h3>The password couldn't be changed: ${err.message ?? 'unknown error'}</h3> | ||
` | ||
) | ||
); | ||
} | ||
}, | ||
]; | ||
@@ -109,0 +107,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
126521
+ Added@accounts/server@1.0.0-alpha-20231120164530-e14d6a81(transitive)
+ Added@accounts/two-factor@1.0.0-alpha-20231120164530-e14d6a81(transitive)
+ Added@accounts/types@1.0.0-alpha-20231120164530-e14d6a81(transitive)
- Removed@accounts/server@1.0.0-alpha-20231120163547-4a461fcc(transitive)
- Removed@accounts/two-factor@1.0.0-alpha-20231120163547-4a461fcc(transitive)
- Removed@accounts/types@1.0.0-alpha-20231120163547-4a461fcc(transitive)
Updated@accounts/two-factor@1.0.0-alpha-20231120164530-e14d6a81