Skip to content

Commit cd5c4ae

Browse files
committed
udpate to cbauth 5
1 parent 8596f3b commit cd5c4ae

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

interfaces/IAuthService.cfc

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ interface{
99
/**
1010
* Get the authenticated user
1111
*
12+
* @throws NoUserLoggedIn : If the user is not logged in
13+
*
1214
* @return User that implements IAuthUser
13-
* @throws NoUserLoggedIn
1415
*/
1516
any function getUser();
1617

@@ -20,20 +21,24 @@ interface{
2021
boolean function isLoggedIn();
2122

2223
/**
23-
* Attemps to log in a user
24+
* Try to authenticate a user into the system. If the authentication fails an exception is thrown, else the logged in user object is returned
2425
*
2526
* @username The username to log in with
2627
* @password The password to log in with
2728
*
2829
* @throws InvalidCredentials
30+
*
31+
* @return User : The logged in user object
2932
*/
30-
boolean function authenticate( required username, required password );
33+
any function authenticate( required username, required password );
3134

3235
/**
33-
* Logs a user into the system
34-
*
35-
* @user The user object that implements IAuthUser
36-
*/
36+
* Login a user into our persistent scopes
37+
*
38+
* @user The user object to log in
39+
*
40+
* @return The same user object so you can do functional goodness
41+
*/
3742
function login( required user );
3843

3944
/**

models/jwt/JwtService.cfc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,12 @@ component accessors="true" singleton {
136136
required password,
137137
struct customClaims = {}
138138
){
139-
var auth = cbSecurity.getAuthService();
140-
141-
if ( auth.authenticate( arguments.username, arguments.password ) ) {
142-
// Create it
143-
return fromUser( auth.getUser(), arguments.customClaims );
144-
} else {
145-
// Can't do anything if the authenticate is false.
146-
throw( message = "The credentials are invalid!", type = "InvalidCredentials" );
147-
}
139+
var oUser = cbSecurity
140+
.getAuthService()
141+
.authenticate( arguments.username, arguments.password );
142+
143+
// Create it
144+
return fromUser( oUser, arguments.customClaims );
148145
}
149146

150147
/**

0 commit comments

Comments
 (0)