user
- Description:
-
-
User API. Collection of functions to control data of user with
localStorage
-
- Source:
- Since:
-
- 22.03.17
Properties:
Name | Type | Description |
---|---|---|
_uid |
Object |
Object which contains functions to generate texts for user ID. See bim.app.user._uid for more details. |
token |
Object |
Object which contains functions to set or get user token. See bim.app.user.token for more details. |
name |
function |
Function to get user name from local storage if exists. See bim.app.user.name for more details. |
uid |
function |
Function to get user ID from local storage if exists. See bim.app.user.uid for more details. |
loggedIn |
function |
Function to check whether user is logged in or not. See bim.app.user.loggedIn for more details. |
register |
function |
Function to register user information to local storage. See bim.app.user.register for more details. |
logout |
function |
Function to log out user. See bim.app.user.logout for more details. |
Members
(static) _uid :Object
- Description:
-
-
Object which contains functions to generate texts for user ID.
-
- Source:
Properties:
Name | Type | Description |
---|---|---|
text |
function |
Function to serve randomly generated text. |
generate |
function |
Function to serve randomly generated text with date. |
Object which contains functions to generate texts for user ID.
Type:
- Object
Examples
bim.app.user._uid.text();
bim.app.user._uid.generate();
(static) token :Object
- Description:
-
-
Object which contains functions to set or get the item, user token, to
localStorage
using "token" as the key.
-
- Source:
Properties:
Name | Type | Description |
---|---|---|
set |
function |
Function to set |
get |
function |
Function to get |
Object which contains functions to set or get the item, user
token, to localStorage
using "token" as the
key.
Type:
- Object
Example
bim.app.user.token.get();
Methods
(static) name(callback) → {string|boolean}
- Description:
-
-
Searches by "user" from local storage, if exists, calls callback function with it as a parameter and returns it. Else, returns false.
-
- Source:
Example
bim.app.user.name();
Parameters:
Name | Type | Description |
---|---|---|
callback |
callback |
Returns:
localStorage
item using key "user" |
false
- Type
- string | boolean
(static) uid(callback) → {*|boolean}
- Description:
-
-
Searches by "uid" from local storage, if exists, calls callback function with it as a parameter and returns it. Else, returns false.
-
- Source:
Example
bim.app.user.uid();
Parameters:
Name | Type | Description |
---|---|---|
callback |
callback |
Returns:
localStorage's item using key "uid" | false
- Type
- * | boolean
(static) loggedIn(callbackopt) → {*|boolean}
- Description:
-
-
Function to check whether user is logged in or not. Check items with "uid" & "user", as keys, from localstorage. If callback is a function, calls it with existence of items (true, false) as parameter. Else, returns whether they exist or not.
-
- Source:
Example
bim.app.user.loggedIn(${1:callback});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function | <optional> |
Optional. Callback function |
Returns:
Result of callback if it is a function | Whether logged in or not.
true
, false
- Type
- * | boolean
(static) register(params, callbackopt) → {*|Object}
- Description:
-
-
Function to register user information to local storage. Saves data "user", "uid" into
localStorage
.
-
- Source:
Examples
// Without callback function
bim.app.user.register({name : ${1:userName}, uid : ${2:userId}});
// With callback function
bim.app.user.register({name : ${1:userName}, uid : ${2:userId}}, ${3:callback});
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
Required. Properties
|
||||||||||
callback |
function | <optional> |
Returns:
If callback is function, returns the result of callback with Object using {name, uid} property as a parameter. Else, returns Object having property {name, uid}.
- Type
- * | Object
(static) logout()
- Description:
-
-
Function to log out user. Removes data "user", "uid" from
localStorage
.
-
- Source:
Example
bim.app.user.logout();