(function() { var jmId_0;jmId_0 = (function(jmId_1) { var jmId_2;jmId_2 = jmId_1.replace("-", "+").replace("_", "\/");switch ((jmId_2.length % 4)) { case (0): break;case (2): jmId_2 = (jmId_2 + "==");break;case (3): jmId_2 = (jmId_2 + "=");break;default: throw("Illegal base64url string!"); };return window.atob(jmId_2); });var jmId_3;jmId_3 = angular.module("happstackAuthentication", []);jmId_3.controller("AuthenticationCtrl", ["$scope", "userService", (function(jmId_4, jmId_5) { jmId_4.isAuthenticated = jmId_5.getUser().isAuthenticated;jmId_4.$watch((function() { return jmId_5.getUser().isAuthenticated; }), (function(jmId_6, jmId_7) { jmId_4.isAuthenticated = jmId_6; }));jmId_4.claims = jmId_5.getUser().claims;jmId_4.$watch((function() { return jmId_5.getUser().claims; }), (function(jmId_8, jmId_9) { jmId_4.claims = jmId_8; }));jmId_4.logout = (function() { jmId_5.clearUser();document.cookie = "atc=; path=\/; expires=Thu, 01-Jan-70 00:00:01 GMT;"; }); })]);jmId_3.factory("userService", ["$rootScope", (function(jmId_10) { var jmId_11;jmId_11 = { 'clearUser': (function() { this.setUser({ 'claims': {}, 'isAuthenticated': false, 'token': null }); }), 'getUser': (function() { return this.userCache; }), 'setUser': (function(jmId_12) { this.userCache = jmId_12;localStorage.setItem("user", JSON.stringify(jmId_12)); }), 'updateFromToken': (function(jmId_13) { var jmId_14;jmId_14 = jmId_13.split(".")[1];var jmId_15;jmId_15 = JSON.parse(jmId_0(jmId_14));u = this.getUser();u.isAuthenticated = true;u.token = jmId_13;u.claims = jmId_15;this.setUser(u);return u; }), 'userCache': null, 'userCacheInit': (function() { var jmId_16;jmId_16 = localStorage.getItem("user");if(jmId_16) { this.setUser(JSON.parse(jmId_16)); } else { jmId_11.clearUser(); }; }) };jmId_11.userCacheInit();return jmId_11; })]);var jmId_17;jmId_17 = angular.module("usernamePassword", ["happstackAuthentication"]);jmId_17.controller("UsernamePasswordCtrl", ["$scope", "$http", "$window", "$location", "userService", (function(jmId_18, jmId_19, jmId_20, jmId_21, jmId_22) { jmId_18.login = (function() { jmId_19.post("http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/token", jmId_18.user).success((function(jmId_23, jmId_24, jmId_25, jmId_26) { jmId_18.username_password_error = "";jmId_22.updateFromToken(jmId_23.token); })).error((function(jmId_27, jmId_28, jmId_29, jmId_30) { jmId_22.clearUser();jmId_18.username_password_error = jmId_27.error; })); });jmId_18.signupPassword = (function() { jmId_18.signup.naUser.userId = 0;jmId_19.post("http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/account", jmId_18.signup).success((function(jmId_31, jmId_32, jmId_33, jmId_34) { jmId_18.signup_error = "Account Created";jmId_18.signup = {}; })).error((function(jmId_35, jmId_36, jmId_37, jmId_38) { jmId_18.signup_error = jmId_35.error; })); });jmId_18.changePassword = (function(jmId_39) { var jmId_40;jmId_40 = jmId_22.getUser();if(jmId_40.isAuthenticated) { jmId_19.post(jmId_39, jmId_18.password).success((function(jmId_41, jmId_42, jmId_43, jmId_44) { jmId_18.change_password_error = "Password Changed.";jmId_18.password = {}; })).error((function(jmId_45, jmId_46, jmId_47, jmId_48) { jmId_18.change_password_error = jmId_45.error; })); } else { jmId_18.change_password_error = "Not Authenticated."; }; });jmId_18.requestResetPassword = (function() { jmId_19.post("http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/password-request-reset", jmId_18.requestReset).success((function(jmId_49, jmId_50, jmId_51, jmId_52) { jmId_18.request_reset_password_msg = jmId_49; })).error((function(jmId_53, jmId_54, jmId_55, jmId_56) { jmId_18.request_reset_password_msg = jmId_53.error; })); });jmId_18.resetPassword = (function() { var jmId_57;jmId_57 = jmId_21.search().reset_token;if(jmId_57) { jmId_18.reset.rpResetToken = jmId_57;jmId_19.post("http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/password-reset", jmId_18.reset).success((function(jmId_58, jmId_59, jmId_60, jmId_61) { jmId_18.reset_password_msg = jmId_58; })).error((function(jmId_62, jmId_63, jmId_64, jmId_65) { jmId_18.reset_password_msg = jmId_62.error; })); } else { jmId_18.reset_password_msg = "reset token not found."; }; }); })]);jmId_17.factory("authInterceptor", ["$rootScope", "$q", "$window", "userService", (function(jmId_66, jmId_67, jmId_68, jmId_69) { return { 'request': (function(jmId_70) { jmId_70.headers = (jmId_70.headers || {});u = jmId_69.getUser();if((u && u.token)) { jmId_70.headers.Authorization = ("Bearer " + u.token); };return jmId_70; }), 'responseError': (function(jmId_71) { if((jmId_71.status === 401)) { };return jmId_67.reject(jmId_71); }) }; })]);jmId_17.config(["$httpProvider", (function(jmId_72) { jmId_72.interceptors.push("authInterceptor"); })]);jmId_17.directive("upAuthenticated", ["$rootScope", "userService", (function(jmId_73, jmId_74) { return { 'link': (function(jmId_75, jmId_76, jmId_77) { var jmId_78;jmId_78 = jmId_76.css("display");jmId_73.$watch((function() { return jmId_74.getUser().isAuthenticated; }), (function(jmId_79) { if((jmId_79 != (jmId_77.upAuthenticated == "true"))) { jmId_76.css("display", "none"); } else { jmId_76.css("display", jmId_78); }; })); }), 'restrict': "A" }; })]);jmId_17.directive("upLogout", ["$rootScope", "userService", (function(jmId_80, jmId_81) { return { 'replace': true, 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/partial\/logout" }; })]);jmId_17.directive("upLoginInline", ["$rootScope", "userService", (function(jmId_82, jmId_83) { return { 'replace': true, 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/partial\/login-inline" }; })]);jmId_17.directive("upChangePassword", ["$rootScope", "$http", "$compile", "userService", (function(jmId_84, jmId_85, jmId_86, jmId_87) { var jmId_88;jmId_88 = (function(jmId_89, jmId_90, jmId_91) { jmId_84.$watch((function() { return jmId_87.getUser().isAuthenticated; }), (function(jmId_92) { if((jmId_92 == true)) { jmId_85.get("http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/partial\/change-password").success((function(jmId_93, jmId_94, jmId_95, jmId_96) { jmId_90.empty();var jmId_97;jmId_97 = angular.element(jmId_93);jmId_90.append(jmId_97);jmId_86(jmId_97)(jmId_89); })); } else { jmId_90.empty(); }; })); });return { 'link': jmId_88, 'restrict': "E" }; })]);jmId_17.directive("upRequestResetPassword", [(function() { return { 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/partial\/request-reset-password-form" }; })]);jmId_17.directive("upResetPassword", [(function() { return { 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/partial\/reset-password-form" }; })]);jmId_17.directive("upSignupPassword", [(function() { return { 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/password\/partial\/signup-password" }; })]);var jmId_98;jmId_98 = angular.module("openId", ["happstackAuthentication"]);var jmId_99;tokenCB = (function(jmId_100) { alert(("tokenCB: " + jmId_100)); });jmId_98.controller("OpenIdCtrl", ["$scope", "$http", "$window", "$location", "userService", (function(jmId_101, jmId_102, jmId_103, jmId_104, jmId_105) { jmId_101.openIdRealm = { 'srOpenIdRealm': "" };jmId_101.openIdWindow = (function(jmId_106) { tokenCB = (function(jmId_107) { var jmId_108;jmId_108 = jmId_105.updateFromToken(jmId_107);jmId_101.isAuthenticated = jmId_108.isAuthenticated;jmId_101.$apply(); });jmId_99 = window.open(jmId_106, "_blank", "toolbar=0"); });jmId_101.setOpenIdRealm = (function(jmId_109) { return jmId_102.post(jmId_109, jmId_101.openIdRealm).success((function(jmId_110, jmId_111, jmId_112, jmId_113) { jmId_101.set_openid_realm_msg = "Realm Updated."; })).error((function(jmId_114, jmId_115, jmId_116, jmId_117) { jmId_101.set_openid_realm_msg = jmId_114.error; })); }); })]);jmId_98.directive("openidGoogle", ["$rootScope", (function(jmId_118) { return { 'replace': true, 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/openId\/partial\/using-google" }; })]);jmId_98.directive("openidYahoo", ["$rootScope", (function(jmId_119) { return { 'replace': true, 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/openId\/partial\/using-yahoo" }; })]);jmId_98.directive("openidRealm", ["$rootScope", (function(jmId_120) { return { 'restrict': "E", 'templateUrl': "http:\/\/www.happstack.com\/authenticate\/auth\/authentication-methods\/openId\/partial\/realm" }; })]); })();