Skip to content

Commit

Permalink
Merge pull request Langres-App#176 from Langres-App/77-debug-account-…
Browse files Browse the repository at this point in the history
…creation-not-log-in-automatically-and-add-message-error

77 debug account creation not log in automatically and add message error
  • Loading branch information
kiloutyg authored Mar 21, 2024
2 parents b5c62b1 + a3eaab9 commit 9231cfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions FRONT/js/data/dao/AuthDao.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class AuthDao extends Dao {
*/
async login(user) {
let resp = await this.post('/login', user);
return await resp.text();
if (resp.status === 200) {
return await resp.text();
}
}

/**
Expand All @@ -44,7 +46,9 @@ class AuthDao extends Dao {
*/
async register(user) {
let resp = await this.post('/register', user);
return await resp.text();
if (resp.status === 201) {
return await resp.text();
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions FRONT/js/model/auth/AuthManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class AuthManager {
*/
async login(user) {
let response = await this.dao.login(user);
if (!response) throw new Error('Login failed');
this.#setToken(response);
}

Expand All @@ -78,6 +79,7 @@ class AuthManager {
*/
async register(user) {
let response = await this.dao.register(user);
if (!response) throw new Error('Login failed');
this.#setToken(response);
}

Expand Down

0 comments on commit 9231cfb

Please sign in to comment.