Skip to content

Commit 4e132a4

Browse files
feat(#293):loadByUsername should have access to http context
feat(#293):loadByUsername should have access to http context
1 parent fac9ae7 commit 4e132a4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

main-core/mandarine-native/security/authenticatorDefault.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Authenticator implements Mandarine.Security.Auth.Authenticator {
4444
*
4545
* @param data Contains the information to execute the authentication such as user & password. It takes an optional value for `executer` which is a function to be executed when authentication is done (if successful)
4646
*/
47-
public performAuthentication(data: Mandarine.Security.Auth.PerformAuthenticationOptions): [Mandarine.Security.Auth.AuthenticationResult, Mandarine.Security.Auth.UserDetails | undefined] {
47+
public performAuthentication(data: Mandarine.Security.Auth.PerformAuthenticationOptions, httpContext?: Mandarine.Types.RequestContext): [Mandarine.Security.Auth.AuthenticationResult, Mandarine.Security.Auth.UserDetails | undefined] {
4848
const { username, password, executer } = data;
4949
const throwUserError = () => new MandarineAuthenticationException("User does not exist", Mandarine.Security.Auth.AuthExceptions.INVALID_USER);
5050
const throwPasswordError = () => new MandarineAuthenticationException("Password is invalid", Mandarine.Security.Auth.AuthExceptions.INVALID_PASSWORD);
@@ -59,7 +59,7 @@ export class Authenticator implements Mandarine.Security.Auth.Authenticator {
5959
if(!this.verifyAuthenticationSatisfaction(false)) throw new MandarineSecurityException(MandarineSecurityException.UNSATISFIED_AUTHENTICATOR);
6060

6161
const getAuthManagerBuilder = Mandarine.Security.getAuthManagerBuilder();
62-
const userDetailsLookUpOriginal = getAuthManagerBuilder.getUserDetailsService().loadUserByUsername(username);
62+
const userDetailsLookUpOriginal = getAuthManagerBuilder.getUserDetailsService().loadUserByUsername(username, httpContext);
6363

6464
if(!userDetailsLookUpOriginal) {
6565
throw throwUserError();
@@ -123,7 +123,7 @@ export class Authenticator implements Mandarine.Security.Auth.Authenticator {
123123
executer: data.executers?.authExecuter
124124
};
125125

126-
const [authenticate, userDetails] = this.performAuthentication(authenticationData);
126+
const [authenticate, userDetails] = this.performAuthentication(authenticationData, requestContext);
127127

128128
const authenticationObject = Object.assign({}, authenticate);
129129

security-core/mandarine-security.ns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export namespace MandarineSecurity {
226226
*
227227
* @throws MandarineSecurityException if no user was found.
228228
*/
229-
loadUserByUsername: (username: string) => UserDetails | undefined;
229+
loadUserByUsername: (username: string, httpContext?: Mandarine.Types.RequestContext) => UserDetails | undefined;
230230
}
231231

232232
/**

0 commit comments

Comments
 (0)