concourse-client/src/util/Auth.js
/**
 * Retrieves a new token from the backend
 * 
 * @param {string} username the username to authenticate with
 * @param {string} password the password to authenticate with
 * @param {Boolean} persist_session whether to retrieve a persistent session token as well as the temporary token
 * 
 * If this request succeeds, a token will be returned in an HTTPOnly cookie.
 * Additionally, a JSON object containing information on the newly-
 * authenticated user and the token ID (for later invalidation)
 */
Retrieves a new token from the backend

@param {string} username the username to authenticate with
@param {string} password the password to authenticate with
@param {Boolean} persist_session whether to retrieve a persistent session token as well as the temporary token

If this request succeeds, a token will be returned in an HTTPOnly cookie.
Additionally, a JSON object containing information on the newly
authenticated user and the token ID (for later invalidation)
Retrieves a new token from the backend @param { string } username the username to authenticate with @param { string } password the password to authenticate with @param { Boolean } persist_session whether to retrieve a persistent session token as well as the temporary token If this request succeeds a token will be returned in an HTTPOnly cookie . Additionally a JSON object containing information on the newly authenticated user and the token ID ( for later invalidation )
async function Login(username, password, persist_session){
    if(persist_session){
        console.error("Persistent sessions are not yet implemented. This option will be ignored.")
    }
    const res =  await fetch(`${Backend()}/api/v1/login`, {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            method: 'local',
            username: username,
            password: password
        })
    })
    return {
        success: res.status === 200,
        res: res.json()
    }
}
async function Login ( username , password , persist_session ) { if ( persist_session ) { console . error ( "Persistent sessions are not yet implemented. This option will be ignored." ) } const res = await fetch ( ` ${ Backend ( ) } ` , { method : 'POST' , headers : { 'Accept' : 'application/json' , 'Content-Type' : 'application/json' } , body : JSON . stringify ( { method : 'local' , username : username , password : password } ) } ) return { success : res . status === 200 , res : res . json ( ) } }
Retrieves a new token from the backend
Retrieves a new token from the backend