Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tas 8 helper methods for authentication #20

Conversation

markgcera
Copy link
Contributor

Pull Request

Description

Create authentication.ts file with helper methods for user sign in and sign out.

Related Issues

Checklist

Please review and check the following before submitting your pull request:

  • I have read the CONTRIBUTING.md document.
  • My code follows the code style of this project.
  • I have written tests for my changes (if applicable).
  • All new and existing tests passed.
  • I have updated the documentation accordingly (if applicable).
  • I have added comments to my code, particularly in areas that may be confusing.

Screenshots (if applicable)

Desktop

Mobile

Additional Information

Reviewer Notes

Comment on lines +1 to +3
const BASE_URL = 'https://example.com/auth';
const LOGIN_URL = `${BASE_URL}/login`;
const LOGOUT_URL = `${BASE_URL}/logout`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use resolveURL function from @/src/api/fetch

throw new Error('Failed to sign in');
}

return response.json();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return response object and not json

// Clear cookies on the client side
document.cookie.split(';').forEach(cookie => {
document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/');
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return response too, in case sign out failed and errors can be handled

method: 'POST',
headers: {
'Content-Type': 'application/json',
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to set credentials to include to save csrf token

@markgcera markgcera mentioned this pull request Feb 13, 2024
6 tasks
@markgcera markgcera closed this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants