angular.module("app.controllers").controller("AccessCodeLoginController",["$rootScope","$scope","$http","$facebook","constantKeys","toaster",function(n,t,i){function r(n){n=n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var i=new RegExp("[\\?&]"+n+"=([^&#]*)"),t=i.exec(location.search);return t==null?"":decodeURIComponent(t[1].replace(/\+/g," "))}t.Authentication={AccountName:null,AccountHelp:!1,Initialize:function(){},IsLoading:!1,Item:{AccessCode:null},OauthUser:{},PasswordLinkEmailed:!1,Methods:{AccessCode:function(){t.Authentication.Services.AccessCode(t.Authentication.Item)},LoggedInWithAccessCode:function(i){t.Authentication.IsLoading=!1;var u=JSON.parse(i);if(u!="Authentication Failed"){if(i=="")return;n.Token=u;n.IsLoggedIn=!0;t.Authentication.Services.AddActivityOnlyOnce({Token:n.Token,ActivityTypeId:1});window.location.href=r("redirect")!=""?r("redirect"):"/Home/MyAccount?action=AccessCode"}else alert("Access code invalid or expired.")}},Services:{AccessCode:function(n){i.post("/authentication/LoginWithAccessCode",n).success(t.Authentication.Methods.LoggedInWithAccessCode)},AddActivityOnlyOnce:function(n){i.post("/api/events/AddActivityOnlyOnce",n)}}};t.Authentication.Initialize()}])