# new auth()
Class for handling the login
Members
# (static) loginCallback :Callable
a callback that gets executed, when a login succeeds
Type:
- Callable
# (static) loginCallback :Callable
a callback that gets executed, when a login succeeds
Type:
- Callable
# (static) token :string|null
the access token for the api
Type:
- string | null
# (static) token :string|null
the access token for the api
Type:
- string | null
# (static) user :object|null
the user array
Type:
- object | null
# (static) user :object|null
the user array
Type:
- object | null
Methods
# (static) autoLogin() → {Promise.<boolean>}
Function for automatically logging in (e.g. on page reload)
Returns:
true on success and logged in
- Type
- Promise.<boolean>
Example
if(await j.auth.autoLogin())
{
console.log("logged in");
}
else
{
console.log("not logged in");
}
# (static) autoLogin() → {Promise.<boolean>}
Function for automatically logging in (e.g. on page reload)
Returns:
true on success and logged in
- Type
- Promise.<boolean>
Example
if(await j.auth.autoLogin())
{
console.log("logged in");
}
else
{
console.log("not logged in");
}
# (static) canTryAutoLogin() → {boolean}
Checks if there is stored data to try the autologin
Returns:
- Type
- boolean
# (static) canTryAutoLogin() → {boolean}
Checks if there is stored data to try the autologin
Returns:
- Type
- boolean
# (static) isLoggedIn() → {boolean}
Function for checking if logged in
Returns:
true if logged in
- Type
- boolean
Example
if (!j.auth.isLoggedIn())
{
// not logged in
}
# (static) isLoggedIn() → {boolean}
Function for checking if logged in
Returns:
true if logged in
- Type
- boolean
Example
if (!j.auth.isLoggedIn())
{
// not logged in
}
# (static) login(username, password, remember) → {Promise.<boolean>}
Function for logging in
Parameters:
Name | Type | Description |
---|---|---|
username |
string | the username |
password |
string | the password |
remember |
boolean | wether to save the login for later use |
Returns:
true on success
- Type
- Promise.<boolean>
Example
if(await j.auth.login("user","pass",true))
{
console.log("logged in");
}
else
{
console.log("not logged in");
}
# (static) login(username, password, remember) → {Promise.<boolean>}
Function for logging in
Parameters:
Name | Type | Description |
---|---|---|
username |
string | the username |
password |
string | the password |
remember |
boolean | wether to save the login for later use |
Returns:
true on success
- Type
- Promise.<boolean>
Example
if(await j.auth.login("user","pass",true))
{
console.log("logged in");
}
else
{
console.log("not logged in");
}
# (static) logout() → {Promise}
Function for logging out (and removing saved login data)
Returns:
- Type
- Promise
Example
j.auth.logout().then(() => console.log("logged out"));
# (static) logout() → {Promise}
Function for logging out (and removing saved login data)
Returns:
- Type
- Promise
Example
j.auth.logout().then(() => console.log("logged out"));
# (static) modal(callbacknullable, dismissablenullable) → {Promise}
Function opening a modal with a login form
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
Callable |
<nullable> |
a callback to execute when login succeeds |
dismissable |
boolean |
<nullable> |
when false, the modal cannot be closed until the user logs in. |
Returns:
- Type
- Promise
Example
j.query("#loginButton").on('click', () => j.auth.modal());
# (static) modal(callbacknullable, dismissablenullable) → {Promise}
Function opening a modal with a login form
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
Callable |
<nullable> |
a callback to execute when login succeeds |
dismissable |
boolean |
<nullable> |
when false, the modal cannot be closed until the user logs in. |
Returns:
- Type
- Promise
Example
j.query("#loginButton").on('click', () => j.auth.modal());