Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // *------------------------------------------*
- // [JAKISCOMPONENT] WOLA LOGINSERVICE
- // *------------------------------------------*
- ({
- /**
- * HELPER
- */
- handleLogin: function(component, hasVerificationCode) {
- this.loginService.invokeLogin(
- component.get('v.loginParams'),
- decodeURIComponent(component.get('v.startUrl')),
- (hasVerificationCode ? '' : component.get('v.verificationCode'))
- ).then(res => {
- if(component.get('v.showError')) {
- this.toggleError(component, '', false);
- }
- if(res.isTFALoginRequired) {
- component.set('v.maskedUsername', this.maskUsername(component.get('v.loginParams.username')));
- this.handleTwoFactorAuthLogin(component, res);
- } else if(res.isInvalidAuthCode) {
- this.toggleError(component, 'Invalid verification code.', true);
- } else {
- this.handleLoginSuccess(component, res);
- }
- }).catch(err => {
- this.toggleError(component, err[0].message);
- });
- }
- })
- // *------------------------------------------*
- // [LOGINSERVICE] WOLA APEXPROXY
- // *------------------------------------------*
- /*
- * TEMPLATE
- */
- <aura:method name="invokeLogin">
- <aura:attribute name="loginParams" type="Map" />
- <aura:attribute name="startUrl" type="String" />
- <aura:attribute name="verificationCode" type="String" />
- </aura:method>
- ({
- /*
- * CONTROLLER
- */
- invokeLogin: function(component, event, helper) {
- const args = event.getParam("arguments");
- return helper.invokeLogin(component, args);
- },
- /*
- * HELPER
- */
- /**
- * Invokes a server-side action responsible for handling login functionality.
- * @param component {Object} component instance.
- * @param args {Object} a map of parameters passed to the server-side action.
- * @returns {Promise} A promise that will resolve/reject after login is complete.
- */
- invokeLogin: function(component, args) {
- const apexProxy = component.find('apexProxy');
- return apexProxy.invoke(component, 'login', {
- username: args.loginParams.username,
- password: args.loginParams.password,
- startUrl: args.startUrl,
- verificationCode: args.verificationCode
- });
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement