Extends
Members
(static) services
Defines the services required by this provider.
- Source:
(private) _di_allow_defer :boolean
If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.
- boolean
- Inherited From:
- Source:
(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>
Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.
- Source:
(private) _di_deferred_services :Array.<string>
List of services that were deferred and not provided at the time of injection.
- Array.<string>
- Source:
app :module:libflitter/app/FlitterApp~FlitterApp
The Flitter app.
- Inherited From:
- Source:
config :Object
The provider's config.
- Object
- Inherited From:
- Source:
User :module:flitter-auth/model/User~User
The User model's class.
- module:flitter-auth/model/User~User
- Inherited From:
- Source:
Methods
(async, private) _build_user_from_bearer(bearer) → {Promise.<(module:flitter-auth/model/User~User|boolean)>}
Given a bearer token, make a request to configured user endpoint and build a user object from the resultant data.
Name | Type | Description |
---|---|---|
bearer |
string | the bearer token |
- Source:
- User instance if possible, or false if it couldn't be retrieved
- Type
- Promise.<(module:flitter-auth/model/User~User|boolean)>
(private) _get_landing_url() → {string}
Build the URL where the user should be redirected to sign into the OAuth2 provider.
- Source:
- Type
- string
(async, private) _get_user_object(data) → {Promise.<module:flitter-auth/model/User~User>}
Get the user object that matches the specified data. (Data should contain the configured user ID.)
Name | Type | Description |
---|---|---|
data |
object | the user information, including the UID field |
- Source:
- the associated user object
- Type
- Promise.<module:flitter-auth/model/User~User>
(private) _redirect_prompt(res) → {Promise.<*>}
Send the login page view to the response.
Name | Type | Description |
---|---|---|
res |
express/response | the response |
- Source:
- Type
- Promise.<*>
(async, private) _update_user_attributes(user, data) → {Promise.<*>}
Updates the attributes on the provided {module:flitter-auth/model/User~User} instance with the specified data.
Name | Type | Description |
---|---|---|
user |
module:flitter-auth/model/User~User | the user to update |
data |
object | the data attributes to update |
- Source:
- Type
- Promise.<*>
(async) check_user_auth(user, password) → {Promise.<boolean>}
Check the validity of the provided credentials.
Name | Type | Description |
---|---|---|
user |
string | |
password |
string |
- Inherited From:
- Source:
- true if the credentials succeed, false otherwise
- Type
- Promise.<boolean>
(async) cleanup(app) → {Promise.<void>}
Clean up resources used by this provider.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the current app |
- Inherited From:
- Source:
- Type
- Promise.<void>
(async) get_login_args(form_data) → {Promise.<Array.<string>>}
From the form data, get the formatted arguments to be passed into the login function. Should create the username and password params.
Name | Type | Description |
---|---|---|
form_data |
Object |
- Inherited From:
- Source:
- Type
- Promise.<Array.<string>>
(async) get_registration_args(form_data) → {Promise.<Array.<*>>}
From the form data, get the formatted arguments to be passed into the registration function. Should create the username and {password} objects.
Name | Type | Description |
---|---|---|
form_data |
Object |
- Inherited From:
- Source:
- Type
- Promise.<Array.<*>>
(async) handle_login_get(req, res, next) → {Promise.<*>}
Handles a GET request to the login route.
Name | Type | Description |
---|---|---|
req |
express/request | the request |
res |
express/response | the response |
next |
function | the next function in the stack |
- Source:
- Type
- Promise.<*>
(async) handle_register_get(req, res, next) → {Promise.<*>}
Handles a GET request to the register route.
Name | Type | Description |
---|---|---|
req |
express/request | the request |
res |
express/response | the response |
next |
function | the next function in the stack |
- Source:
- Type
- Promise.<*>
(async) login(username, password, argsopt) → {Promise.<(boolean|module:flitter-auth/model/User~User)>}
Attempt to authenticate a user with the provided credentials. If it succeeds, return their User object.
Name | Type | Attributes | Description |
---|---|---|---|
username |
string | ||
password |
string | ||
args |
<optional> |
not required |
- Inherited From:
- Source:
- false if the auth is unsuccessful, a User instance if it is
- Type
- Promise.<(boolean|module:flitter-auth/model/User~User)>
login_view() → {string}
Get the view for the login page.
- Source:
- Type
- string
(async) logout(request) → {Promise.<object>}
Log out the current user, if there is one, and clean the auth session.
Name | Type | Description |
---|---|---|
request |
express/Request |
- Inherited From:
- Source:
- the clean session
- Type
- Promise.<object>
logout_view() → {string}
Get the Flitter canonical name of the logout view.
- Inherited From:
- Source:
- Type
- string
(async) register(username, attrsopt, dataopt) → {Promise.<User>}
Register a new user into whatever system the provider manages. Should also create a valid User document.
Name | Type | Attributes | Description |
---|---|---|---|
username |
string | The UID of the user. Should be unique to Flitter. |
|
attrs |
object |
<optional> |
optionally, other model attributes to be merged in |
data |
object |
<optional> |
optionally, JSON data to be stored in the model |
- Inherited From:
- Source:
- should return a saved user model instance
- Type
- Promise.<User>
registration_view() → {string}
Get the Flitter canonical name of the registration view.
- Inherited From:
- Source:
- Type
- string
(async) session(request, user) → {Promise.<void>}
Bootstrap the session. Sets auth.user and auth.user_id.
Name | Type | Description |
---|---|---|
request |
express/Request | |
user |
module:flitter-auth/model/User~User | the authenticated user |
- Inherited From:
- Source:
- Type
- Promise.<void>
(async) validate_login(form_data) → {Promise.<Array.<string>>}
Ensure that login form_data is valid. Checks for username.
Name | Type | Description |
---|---|---|
form_data |
object |
- Inherited From:
- Source:
- array of string errors. If empty array, no errors.
- Type
- Promise.<Array.<string>>
(async) validate_registration(form_data) → {Promise.<Array.<string>>}
Ensure that registration form_data is valid. Checks for password and unique username.
Name | Type | Description |
---|---|---|
form_data |
object |
- Inherited From:
- Source:
- array of string errors. If empty array, no errors.
- Type
- Promise.<Array.<string>>