mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Compare commits
2 commits
9f4414f68c
...
55156de5f9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55156de5f9 | ||
|
|
b6be822720 |
3 changed files with 13 additions and 5 deletions
|
|
@ -72,9 +72,10 @@ const SimpleLogin: React.FC = () => {
|
||||||
|
|
||||||
<div className="login-links">
|
<div className="login-links">
|
||||||
|
|
||||||
<Link to="/resetPassword">
|
|
||||||
Réinitialiser le mot de passe
|
{/* <Link to="/resetPassword"> */}
|
||||||
</Link>
|
<del>Réinitialiser le mot de passe</del>
|
||||||
|
{/* </Link> */}
|
||||||
|
|
||||||
<Link to="/register">
|
<Link to="/register">
|
||||||
Créer un compte
|
Créer un compte
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,7 @@ class ApiService {
|
||||||
* @returns A error string if unsuccessful,
|
* @returns A error string if unsuccessful,
|
||||||
*/
|
*/
|
||||||
public async register(name: string, email: string, password: string, roles: string[]): Promise<any> {
|
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 {
|
try {
|
||||||
|
|
||||||
if (!email || !password) {
|
if (!email || !password) {
|
||||||
|
|
@ -179,7 +180,8 @@ class ApiService {
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
window.location.href = result.request.responseURL;
|
//window.location.href = result.request.responseURL;
|
||||||
|
window.location.href = '/login';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(`La connexion a échoué. Status: ${result.status}`);
|
throw new Error(`La connexion a échoué. Status: ${result.status}`);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class SimpleAuth {
|
||||||
}
|
}
|
||||||
|
|
||||||
async register(self, req, res) {
|
async register(self, req, res) {
|
||||||
|
console.log(`simpleauth.js.register: ${JSON.stringify(req.body)}`);
|
||||||
try {
|
try {
|
||||||
let userInfos = {
|
let userInfos = {
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
|
|
@ -34,7 +35,11 @@ class SimpleAuth {
|
||||||
roles: req.body.roles
|
roles: req.body.roles
|
||||||
};
|
};
|
||||||
let user = await self.authmanager.register(userInfos)
|
let user = await self.authmanager.register(userInfos)
|
||||||
if (user) res.redirect("/login")
|
if (user) {
|
||||||
|
return res.status(200).json({
|
||||||
|
message: 'User created'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue