Créer compte fonctionne en dev (simpleauth)

This commit is contained in:
C. Fuhrman 2025-03-06 14:48:07 -05:00
parent 9f4414f68c
commit b6be822720
2 changed files with 9 additions and 2 deletions

View file

@ -165,6 +165,7 @@ class ApiService {
* @returns A error string if unsuccessful,
*/
public async register(name: string, email: string, password: string, roles: string[]): Promise<any> {
console.log(`ApiService.register: name: ${name}, email: ${email}, password: ${password}, roles: ${roles}`);
try {
if (!email || !password) {
@ -179,7 +180,8 @@ class ApiService {
console.log(result);
if (result.status == 200) {
window.location.href = result.request.responseURL;
//window.location.href = result.request.responseURL;
window.location.href = '/login';
}
else {
throw new Error(`La connexion a échoué. Status: ${result.status}`);

View file

@ -26,6 +26,7 @@ class SimpleAuth {
}
async register(self, req, res) {
console.log(`simpleauth.js.register: ${JSON.stringify(req.body)}`);
try {
let userInfos = {
name: req.body.name,
@ -34,7 +35,11 @@ class SimpleAuth {
roles: req.body.roles
};
let user = await self.authmanager.register(userInfos)
if (user) res.redirect("/login")
if (user) {
return res.status(200).json({
message: 'User created'
});
}
}
catch (error) {
return res.status(400).json({