Advertisement
kpammi

Client-Side Controller and Helper

Jun 29th, 2016
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. false || function() {
  2.     $A.componentService.addComponentClass("markup://salesforceIdentity:loginForm", function() {
  3.         return {
  4.             meta: {
  5.                 name: "salesforceIdentity$loginForm",
  6.                 "extends": "markup://aura:component"
  7.             },
  8.             controller: {
  9.                 initialize: function(b, a, c) {
  10.                     $A.getEvt("markup://siteforce:registerQueryEventMap").setParams({
  11.                         qsToEvent: c.qsToEventMap
  12.                     }).fire();
  13.                     b.set("v.isUsernamePasswordEnabled", c.getIsUsernamePasswordEnabled(b, a, c));
  14.                     b.set("v.isSelfRegistrationEnabled", c.getIsSelfRegistrationEnabled(b, a, c));
  15.                     b.set("v.communityForgotPasswordUrl", c.getCommunityForgotPasswordUrl(b, a, c));
  16.                     b.set("v.communitySelfRegisterUrl", c.getCommunitySelfRegisterUrl(b, a, c)) //Sets the Community Self Registration URL for anchor Tag with value "Not a member?"
  17.                 },
  18.                 handleLogin: function(b, a, c) {
  19.                     c.handleLogin(b, a, c)
  20.                 },
  21.                 setStartUrl: function(b, a, c) {
  22.                     (a = a.getParam("startURL")) && b.set("v.startUrl", a)
  23.                 },
  24.                 onKeyUp: function(b, a, c) {
  25.                     13 === a.getParam("keyCode") && c.handleLogin(b, a, c)
  26.                 },
  27.                 navigateToForgotPassword: function(b, a, c) {
  28.                     a = b.get("v.communityForgotPasswordUrl");
  29.                     $A.util.isUndefinedOrNull(a) && (a = b.get("v.forgotPasswordUrl"));
  30.                     b = {
  31.                         url: a
  32.                     };
  33.                     $A.getEvt("markup://force:navigateToURL").setParams(b).fire()
  34.                 },
  35.                 navigateToSelfRegister: function(b, a, c) {
  36.                     a = b.get("v.communitySelfRegisterUrl");
  37.                     null == a && (a = b.get("v.selfRegisterUrl"));
  38.                     b = {
  39.                         url: a
  40.                     };
  41.                     $A.getEvt("markup://force:navigateToURL").setParams(b).fire()
  42.                 }
  43.             },
  44.             helper: {
  45.                 qsToEventMap: {
  46.                     startURL: "e.salesforceIdentity:setStartUrl"
  47.                 },
  48.                 handleLogin: function(b, a, c) {
  49.                     a = b.find("username").get("v.value");
  50.                     c = b.find("password").get("v.value");
  51.                     var e = b.get("c.login")
  52.                       , d = b.get("v.startUrl");
  53.                     if (window.salesforceIdentity) {
  54.                         var f = window.salesforceIdentity.getStartUrl();
  55.                         f && (d = f)
  56.                     }
  57.                     d = decodeURIComponent(d);
  58.                     e.setParams({
  59.                         username: a,
  60.                         password: c,
  61.                         startUrl: d
  62.                     });
  63.                     e.setCallback(this, function(a) {
  64.                         a = a.getReturnValue();
  65.                         null !== a && (b.set("v.errorMessage", a),
  66.                         b.set("v.showError", !0))
  67.                     });
  68.                     $A.enqueueAction(e)
  69.                 },
  70.                 getIsUsernamePasswordEnabled: function(b, a, c) {
  71.                     a = b.get("c.getIsUsernamePasswordEnabled");
  72.                     a.setCallback(this, function(a) {
  73.                         a = a.getReturnValue();
  74.                         null !== a && b.set("v.isUsernamePasswordEnabled", a)
  75.                     });
  76.                     $A.enqueueAction(a)
  77.                 },
  78.                 getIsSelfRegistrationEnabled: function(b, a, c) {
  79.                     a = b.get("c.getIsSelfRegistrationEnabled");
  80.                     a.setCallback(this, function(a) {
  81.                         a = a.getReturnValue();
  82.                         null !== a && b.set("v.isSelfRegistrationEnabled", a)
  83.                     });
  84.                     $A.enqueueAction(a)
  85.                 },
  86.                 getCommunityForgotPasswordUrl: function(b, a, c) {
  87.                     a = b.get("c.getForgotPasswordUrl");
  88.                     a.setCallback(this, function(a) {
  89.                         a = a.getReturnValue();
  90.                         null !== a && b.set("v.communityForgotPasswordUrl", a)
  91.                     });
  92.                     $A.enqueueAction(a)
  93.                 },
  94.                 //Function to call the server-side controller function. getSelfRegistrationUrl
  95.                 getCommunitySelfRegisterUrl: function(b, a, c) {
  96.                     a = b.get("c.getSelfRegistrationUrl");
  97.                     a.setCallback(this, function(a) {
  98.                         a = a.getReturnValue();
  99.                         null !== a && b.set("v.communitySelfRegisterUrl", a)
  100.                     });
  101.                     $A.enqueueAction(a)
  102.                 }
  103.             }
  104.         }
  105.     });
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement