Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
auth.authenticate( username, password );
auth.isLoggedIn();
auth.getUser();
auth.logout();interface name="SessionStorageInterface" { // or "RequestStorageInterface"
public any function getVar( required string name, any defaultValue );
public void function setVar( required string name, required any value );
public boolean function deleteVar( required string name );
public boolean function exists( required string name );
}box install cbauth moduleSettings = {
cbauth: {
userServiceClass: "UserService",
// optional, override when needed
sessionStorage: "SessionStorage@cbstorages",
requestStorage: "RequestStorage@cbstorages"
},
//..... other module settings
}interface name="SessionStorageInterface" { // or "RequestStorageInterface"
public any function getVar( required string name, any defaultValue );
public void function setVar( required string name, required any value );
public boolean function deleteVar( required string name );
public boolean function exists( required string name );
}interface {
/**
* Verify if the incoming username/password are valid credentials.
*
* @username The username
* @password The password
*/
boolean function isValidCredentials( required username, required password );
/**
* Retrieve a user by username
*
* @return User that implements IAuthUser
*/
function retrieveUserByUsername( required username );
/**
* Retrieve a user by unique identifier
*
* @id The unique identifier
*
* @return User that implements IAuthUser
*/
function retrieveUserById( required id );
}interface {
/**
* Return the unique identifier for the user
*/
function getId();
}property name="auth" inject="authenticationService@cbauth";
// OR
var auth = wirebox.getInstance( "authenticationService@cbauth" );auth.authenticate( username, password );
auth.isLoggedIn();
auth.getUser();
auth.logout();interface {
/**
* Return the unique identifier for the user
*/
function getId();
/**
* Verify if the user has one or more of the passed in permissions
*
* @permission One or a list of permissions to check for access
*
*/
boolean function hasPermission( required permission );
/**
* Shortcut to verify it the user is logged in or not.
*/
boolean function isLoggedIn();
}interface {
/**
* Verify if the incoming username/password are valid credentials.
*
* @username The username
* @password The password
*/
boolean function isValidCredentials( required username, required password );
/**
* Retrieve a user by username
*
* @return User that implements IAuthUser
*/
function retrieveUserByUsername( required username );
/**
* Retrieve a user by unique identifier
*
* @id The unique identifier
*
* @return User that implements IAuthUser
*/
function retrieveUserById( required id );
}auth() helper is available in handlers, layouts, and views. You will need to use the injection if you need cbauth in other models.property name="auth" inject="authenticationService@cbauth";
// OR
var auth = wirebox.getInstance( "authenticationService@cbauth" );