-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compteBO): acces a mon compte pour userBO 541 (#466)
- Ajout du lien vers les informations de mon compte - Ajustement des droits pour ne pouvoir modifier que son nom est prénom tant au niveau de "mon Compte" que de la gestion des utilisateurs => un utilisateur ne peut plus modifier autre chose que ses informations. - Correction et amélioration de l'affichage des informations "Type de compétence du service " tant en lecture seule qu'en modification (rafraichissement du profil de l'utilisateur connecté)
- Loading branch information
Showing
10 changed files
with
860 additions
and
693 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const BoUser = require("../../services/BoUser"); | ||
|
||
const logger = require("../../utils/logger"); | ||
const ValidationAppError = require("../../utils/validation-error"); | ||
|
||
const BOUserSchema = require("../../schemas/bo-user"); | ||
|
||
const log = logger(module.filename); | ||
|
||
module.exports = async function updateMe(req, res, next) { | ||
log.i("IN", req.body); | ||
const { id } = req.decoded; | ||
let user; | ||
if (id) { | ||
try { | ||
user = await BOUserSchema() | ||
.omit(["email", "deleted", "roles", "territoireCode"]) | ||
.validate(req.body, { | ||
abortEarly: false, | ||
stripUnknown: true, | ||
}); | ||
} catch (error) { | ||
log.w(error); | ||
return next(new ValidationAppError(error)); | ||
} | ||
try { | ||
await BoUser.updateMe(id, user); | ||
return res.status(200).json({ message: "Utilisateur mis à jour" }); | ||
} catch (error) { | ||
log.w("DONE with error"); | ||
return next(error); | ||
} | ||
} else | ||
return res.status(403).json({ | ||
message: "Permission refusée. Utilisateur non reconnu", | ||
}); | ||
}; |
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.