Skip to content
Snippets Groups Projects
Verified Commit b8b75fd6 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Specify return types and async.

parent fc08e172
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!51Fix/authorization
import axios from 'axios';
/**
* @async
* Call for csrf cookie. This cookie is the user session identifier and
* must be sent during the login process.
* @returns csrf cookie
* @returns {string} csrf cookie
*/
export const fetchCookie = async (): Promise<string> =>
axios('/api/web/csrf').then((res) => res.data.token);
import axios from 'axios';
/**
* @async
* Asks for the current set role.
* @returns empty if the role is not set or a name between those defined
* @returns {string} empty if the role is not set or a name between those defined
* in {@see userRoles}
*/
export const getRole = async (): Promise<string> =>
......
import axios from 'axios';
/**
* @async
* Ask the server all the roles of an user if the user has multiple roles.
* @returns array of roles.
* @returns {string[]} array of roles.
*/
export const getRoles = async (): Promise<string[]> =>
axios('/api/web/login/get_roles').then((res) => res.data.roles);
import axios from 'axios';
/**
* @async
* Ask the server if the user is authenticated.
* @returns true or false if the user is authenticated.
* @returns {boolean} true or false if the user is authenticated.
*/
export const isAuthenticated = async (): Promise<boolean> =>
axios('/api/web/login/is_authenticated').then(
......
import axios from 'axios';
/**
* @async
* Set the role of the user in the database.
* @return {string} role
*/
export const setRole = async (role: string): Promise<void> =>
axios.post('/api/web/login/set_role', { role });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment