• JMap.User.login

    The login function, returns a promise. Makes a call to the server and if login is successful resolve the promise providing the user session data.

    If an error occurs, 3 differents string message can be returned :

    • "user.login.error.credential" => Bad username or password
    • "user.login.error.server" => Unexpected error while requesting the server
    • "user.login.error.unexpected" => Unexpected error client side

    Parameters

    • login: string

      The user's username

    • password: string

      The user's password

    Returns Promise<JSessionData>

    Throws

    Error if bad credentials or server error.

    Example

    const userLogin = "jdo@mycompany.com"
    const userPassword = "xxx"

    // Open a new user session, and get back user data from server
    JMap.User
    .login(userLogin, userPassword)
    .then(sessionData => {
    console.log(`User ${userLogin} has been authenticated, his session token is "${sessionData.accessToken}"`)
    })
    .catch(errorKey => {
    console.error(`Cannot loggin ${userLogin}, errorKey="${errorKey}"`, error)
    })