Members
(static) sync
- Source:
Helper function to resync the user's session from the server. This is often used when first loading a webpage or app
just to see if the user's permissions have changed since the user first logged in
from the FluroAuth service itself
Methods
(static) addEventListener(event, callback)
- Source:
Adds a callback that will be triggered whenever the specified event occurs
Example
//Listen for when the user session changes
fluro.auth.addEventListener('change', function(userSession) {})
Parameters:
Name | Type | Description |
---|---|---|
event |
String | The event to listen for |
callback |
function | The function to fire when this event is triggered |
(static) changeAccount(accountID, options) → {Promise}
- Source:
Retrieves a new session object for a Fluro global user for a specified account
This will only work if the user has a persona in that account
Example
fluro.auth.changeAccount('5be504eabf33991239599d63').then(function(userSession) {
//New user session will be set automatically
var newUserSession = fluro.auth.getCurrentUser();
})
fluro.auth.changeAccount('5be504eabf33991239599d63', {disableAutoAuthenticate:true}).then(function(userSession) {
//Set the session manually
fluro.auth.set(userSession)
})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
accountID |
String | The _id of the account you wish to log in to | ||||||
options |
Object |
Properties
|
Returns:
Resolves to the user session object, or rejects with the responding error
- Type
- Promise
(static) getCurrentToken() → {String}
- Source:
Returns the current user's access token
Returns:
The Fluro access token for the current user session
- Type
- String
(static) getCurrentUser() → {Object}
- Source:
Returns the current user's session data
Returns:
The current user session
- Type
- Object
(static) impersonate(personaID, options) → {Promise}
- Source:
Impersonates a persona and sets the current session to match the specified persona's context
Example
fluro.auth.impersonate('5be504eabf33991239599d63')
.then(function(userSession) {
//New user session will be set automatically
var newUserSession = fluro.auth.getCurrentUser();
})
Parameters:
Name | Type | Description |
---|---|---|
personaID |
String | The _id of the persona you wish to impersonate |
options |
Object |
Returns:
Resolves to the user session object, or rejects with the responding error
- Type
- Promise
(static) login(credentials, options) → {Promise}
- Source:
Logs the user in to Fluro and returns a new user session
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
credentials |
Object |
Properties
|
|||||||||
options |
Object | Extra options and configuration for the request
Properties
|
Returns:
Returns a promise that either resolves with the logged in user session, or rejects with the responding error from the server
- Type
- Promise
(static) logout()
- Source:
Deletes the user session object, clears all Fluro caches and tokens
from memory
Example
fluro.auth.logout()
(static) refreshAccessToken(refreshToken, isManagedSession) → {Promise}
- Source:
Helper function to refresh an access token for an authenticated user session. This is usually handled automatically
from the FluroAuth service itself
Parameters:
Name | Type | Description |
---|---|---|
refreshToken |
String | The refresh token to reactivate |
isManagedSession |
Boolean | Whether or not the refresh token is for a managed persona session or a global Fluro user session |
Returns:
A promise that either resolves with the refreshed token details or rejects with the responding error from the server
- Type
- Promise
(static) removeAllListeners()
- Source:
Removes all listening callbacks for all events
Example
fluro.auth.removeAllListeners()
(static) removeEventListener(event, callback)
- Source:
Removes all a callback from the listener list
Example
//Stop listening for the change event
fluro.auth.removeEventListener('change', myFunction)
Parameters:
Name | Type | Description |
---|---|---|
event |
String | The event to stop listening for |
callback |
function | The function to remove from the listener list |
(static) retrieveUserFromResetToken(token, options) → {Promise}
- Source:
Retrieves a user's details by providing a password reset token
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
token |
String | The password reset token that was sent to the user's email address | ||||||
options |
Object | other options for the request
Properties
|
Returns:
Returns a promise that resolves with the reset session details
- Type
- Promise
(static) sendResetPasswordRequest(body, options) → {Promise}
- Source:
Triggers a new Reset Password email request to the specified user.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
body |
Object |
Properties
|
|||||||||
options |
Object | Extra options and configuration for the request
Properties
|
Returns:
Returns a promise that either resolves if the password request was sent, or rejects if an error occurred
- Type
- Promise
(static) set(user)
- Source:
Sets the current user data, often from localStorage or after new session data
has been generated from the server after signing in
Example
FluroAsset.set({firstName:'Jeff', lastName:'Andrews', ...})
Parameters:
Name | Type | Description |
---|---|---|
user |
Object | The user session object |
(static) signup(credentials, options) → {Promise}
- Source:
Signs up a new user to the current application, this will create a new managed user persona
and automatically log in as that persona in the current application context. This function will
only work when called in context of an application with the 'Application Token' authentication style.
It will create a new user persona in the account of the application and return a session with all of the application's
permissions and application's logged in user permissions
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
credentials |
Object |
Properties
|
||||||||||||||||||
options |
Object | Extra options and configuration for the request |
Returns:
Returns a promise that either resolves to the new authenticated session, or rejects with the responding error from the server
- Type
- Promise
(static) updateUserWithToken(token, body, options) → {Promise}
- Source:
Updates a user's details including password by providing a password reset token
Parameters:
Name | Type | Description |
---|---|---|
token |
String | The password reset token that was sent to the user's email address |
body |
Object | The details to change for the user |
options |
Object | other options for the request |
Returns:
Returns a promise that resolves with the reset session details
- Type
- Promise