-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TECH] Migrer la route PATCH /api/account-recovery vers src/identity-…
- Loading branch information
Showing
23 changed files
with
353 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
api/lib/domain/usecases/account-recovery/send-email-for-account-recovery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...rc/identity-access-management/application/account-recovery/account-recovery.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { DomainTransaction } from '../../../shared/domain/DomainTransaction.js'; | ||
import { usecases } from '../../domain/usecases/index.js'; | ||
|
||
const updateUserAccountFromRecoveryDemand = async function (request, h) { | ||
const temporaryKey = request.payload.data.attributes['temporary-key']; | ||
const password = request.payload.data.attributes.password; | ||
|
||
await DomainTransaction.execute(async (domainTransaction) => { | ||
await usecases.updateUserForAccountRecovery({ | ||
password, | ||
temporaryKey, | ||
domainTransaction, | ||
}); | ||
}); | ||
|
||
return h.response().code(204); | ||
}; | ||
|
||
export const accountRecoveryController = { updateUserAccountFromRecoveryDemand }; |
35 changes: 35 additions & 0 deletions
35
api/src/identity-access-management/application/account-recovery/account-recovery.route.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Joi from 'joi'; | ||
import XRegExp from 'xregexp'; | ||
|
||
import { config } from '../../../shared/config.js'; | ||
import { accountRecoveryController } from './account-recovery.controller.js'; | ||
|
||
const { passwordValidationPattern } = config.account; | ||
|
||
export const accountRecoveryRoutes = [ | ||
{ | ||
method: 'PATCH', | ||
path: '/api/account-recovery', | ||
config: { | ||
auth: false, | ||
handler: (request, h) => accountRecoveryController.updateUserAccountFromRecoveryDemand(request, h), | ||
validate: { | ||
payload: Joi.object({ | ||
data: { | ||
attributes: { | ||
'temporary-key': Joi.string().min(32).required(), | ||
password: Joi.string().pattern(XRegExp(passwordValidationPattern)).required(), | ||
}, | ||
}, | ||
}), | ||
options: { | ||
allowUnknown: true, | ||
}, | ||
}, | ||
notes: [ | ||
'- Permet de mettre à jour les informations d’un utilisateur via à une demande de récupération de compte.', | ||
], | ||
tags: ['identity-access-management', 'api', 'account-recovery'], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.