(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("authInterceptor", ["$rootScope", "$q", "$window", "userService", (function(jmId_10, jmId_11, jmId_12, jmId_13) { return { 'request': (function(jmId_14) { jmId_14.headers = (jmId_14.headers || {});u = jmId_13.getUser();if((u && u.token)) { jmId_14.headers.Authorization = ("Bearer " + u.token); };return jmId_14; }), 'responseError': (function(jmId_15) { if((jmId_15.status === 401)) { jmId_13.clearUser();document.cookie = "atc=; path=\/; expires=Thu, 01-Jan-70 00:00:01 GMT;"; };return jmId_11.reject(jmId_15); }) }; })]);jmId_3.config(["$httpProvider", (function(jmId_16) { jmId_16.interceptors.push("authInterceptor"); })]);jmId_3.factory("userService", ["$rootScope", (function(jmId_17) { var jmId_18;jmId_18 = { 'clearUser': (function() { this.setUser({ 'claims': {}, 'isAuthenticated': false, 'token': null }); }), 'getUser': (function() { var jmId_19;jmId_19 = (function(jmId_20) { var jmId_21;jmId_21 = (jmId_20 + "=");var jmId_22;jmId_22 = document.cookie.split(";");var jmId_23;jmId_23 = 0;while((jmId_23 < jmId_22.length)) { var jmId_24;jmId_24 = jmId_22[jmId_23];while((jmId_24.charAt(0) == " ")) { jmId_24 = jmId_24.substring(1); };if((jmId_24.indexOf(jmId_21) == 0)) { return jmId_24.substring(jmId_21.length, jmId_24.length); };jmId_23++; };return ""; });if(((jmId_19("atc").length == 0) && (this.userCache.isAuthenticated == true))) { this.clearUser(); };return this.userCache; }), 'setUser': (function(jmId_25) { this.userCache = jmId_25;localStorage.setItem("user", JSON.stringify(jmId_25)); }), 'updateFromToken': (function(jmId_26) { var jmId_27;jmId_27 = jmId_26.split(".")[1];var jmId_28;jmId_28 = JSON.parse(jmId_0(jmId_27));u = this.getUser();u.isAuthenticated = true;u.token = jmId_26;u.claims = jmId_28;this.setUser(u);return u; }), 'userCache': null, 'userCacheInit': (function() { var jmId_29;jmId_29 = localStorage.getItem("user");if(jmId_29) { this.setUser(JSON.parse(jmId_29)); } else { jmId_18.clearUser(); }; }) };jmId_18.userCacheInit();return jmId_18; })]);var jmId_30;jmId_30 = angular.module("usernamePassword", ["happstackAuthentication"]);jmId_30.controller("UsernamePasswordCtrl", ["$scope", "$http", "$window", "$location", "userService", (function(jmId_31, jmId_32, jmId_33, jmId_34, jmId_35) { emptyUser = (function() { return { 'password': "", 'user': "" }; });jmId_31.user = emptyUser();jmId_31.login = (function() { var jmId_36;jmId_36 = (function(jmId_37, jmId_38, jmId_39, jmId_40) { if((jmId_37 == null)) { jmId_31.username_password_error = "error communicating with the server."; } else { if((jmId_37.jrStatus == "Ok")) { jmId_31.username_password_error = "";jmId_35.updateFromToken(jmId_37.jrData.token); } else { jmId_35.clearUser();jmId_31.username_password_error = jmId_37.jrData; }; }; });jmId_32.post("\/authenticate\/auth\/authentication-methods\/password\/token", jmId_31.user).success(jmId_36).error(jmId_36); });emptySignup = (function() { return { 'naPassword': "", 'naPasswordConfirm': "", 'naUser': { 'email': "", 'username': "" } }; });jmId_31.signup = emptySignup();jmId_31.signupPassword = (function() { jmId_31.signup.naUser.userId = 0;var jmId_41;jmId_41 = (function(jmId_42, jmId_43, jmId_44, jmId_45) { if((jmId_42 == null)) { jmId_31.username_password_error = "error communicating with server."; } else { if((jmId_42.jrStatus == "Ok")) { jmId_31.signup_error = "Account Created";jmId_31.signup = emptySignup(); } else { jmId_31.signup_error = jmId_42.jrData; }; }; });jmId_32.post("\/authenticate\/auth\/authentication-methods\/password\/account", jmId_31.signup).success(jmId_41).error(jmId_41); });emptyPassword = (function() { return { 'cpNewPassword': "", 'cpNewPasswordConfirm': "", 'cpOldPassword': "" }; });jmId_31.password = emptyPassword();jmId_31.changePassword = (function(jmId_46) { var jmId_47;jmId_47 = jmId_35.getUser();var jmId_48;jmId_48 = (function(jmId_49, jmId_50, jmId_51, jmId_52) { if((jmId_49 == null)) { jmId_31.username_password_error = "error communicating with server."; } else { if((jmId_49.jrStatus == "Ok")) { jmId_31.change_password_error = "Password Changed.";jmId_31.password = emptyPassword(); } else { jmId_31.change_password_error = jmId_49.jrData; }; }; });if(jmId_47.isAuthenticated) { jmId_32.post(jmId_46, jmId_31.password).success(jmId_48).error(jmId_48); } else { jmId_31.change_password_error = "Not Authenticated."; }; });requestResetEmpty = (function() { return { 'rrpUsername': "" }; });jmId_31.requestReset = requestResetEmpty();jmId_31.requestResetPassword = (function() { var jmId_53;jmId_53 = (function(jmId_54, jmId_55, jmId_56, jmId_57) { if((jmId_54 == null)) { jmId_31.request_reset_password_msg = "error communicating with the server."; } else { if((jmId_54.jrStatus == "Ok")) { jmId_31.request_reset_password_msg = jmId_54.jrData;jmId_31.requestReset = requestResetEmpty(); } else { jmId_31.request_reset_password_msg = jmId_54.jrData; }; }; });jmId_32.post("\/authenticate\/auth\/authentication-methods\/password\/password-request-reset", jmId_31.requestReset).success(jmId_53).error(jmId_53); });resetEmpty = (function() { return { 'rpPassword': "", 'rpPasswordConfirm': "" }; });jmId_31.reset = resetEmpty();jmId_31.resetPassword = (function() { var jmId_58;jmId_58 = (function(jmId_59, jmId_60, jmId_61, jmId_62) { if((jmId_59 == null)) { jmId_31.reset_password_msg = "error communicating with the server."; } else { if((jmId_59.jrStatus == "Ok")) { jmId_31.reset_password_msg = jmId_59.jrData;jmId_31.reset = resetEmpty(); } else { jmId_31.reset_password_msg = jmId_59.jrData; }; }; });var jmId_63;jmId_63 = jmId_34.search().reset_token;if(jmId_63) { jmId_31.reset.rpResetToken = jmId_63;jmId_32.post("\/authenticate\/auth\/authentication-methods\/password\/password-reset", jmId_31.reset).success(jmId_58).error(jmId_58); } else { jmId_31.reset_password_msg = "reset token not found."; }; }); })]);jmId_30.directive("upAuthenticated", ["$rootScope", "userService", (function(jmId_64, jmId_65) { return { 'link': (function(jmId_66, jmId_67, jmId_68) { var jmId_69;jmId_69 = jmId_67.css("display");jmId_64.$watch((function() { return jmId_65.getUser().isAuthenticated; }), (function(jmId_70) { if((jmId_70 != (jmId_68.upAuthenticated == "true"))) { jmId_67.css("display", "none"); } else { jmId_67.css("display", jmId_69); }; })); }), 'restrict': "A" }; })]);jmId_30.directive("upLogout", ["$rootScope", "userService", (function(jmId_71, jmId_72) { return { 'replace': true, 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/password\/partial\/logout" }; })]);jmId_30.directive("upLogin", ["$rootScope", "userService", (function(jmId_73, jmId_74) { return { 'replace': true, 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/password\/partial\/login" }; })]);jmId_30.directive("upLoginInline", ["$rootScope", "userService", (function(jmId_75, jmId_76) { return { 'replace': true, 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/password\/partial\/login-inline" }; })]);jmId_30.directive("upChangePassword", ["$rootScope", "$http", "$compile", "userService", (function(jmId_77, jmId_78, jmId_79, jmId_80) { var jmId_81;jmId_81 = (function(jmId_82, jmId_83, jmId_84) { jmId_77.$watch((function() { return jmId_80.getUser().isAuthenticated; }), (function(jmId_85) { if((jmId_85 == true)) { jmId_78.get("\/authenticate\/auth\/authentication-methods\/password\/partial\/change-password").success((function(jmId_86, jmId_87, jmId_88, jmId_89) { jmId_83.empty();var jmId_90;jmId_90 = angular.element(jmId_86);jmId_83.append(jmId_90);jmId_79(jmId_90)(jmId_82); })); } else { jmId_83.empty(); }; })); });return { 'link': jmId_81, 'restrict': "E" }; })]);jmId_30.directive("upRequestResetPassword", [(function() { return { 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/password\/partial\/request-reset-password-form" }; })]);jmId_30.directive("upResetPassword", [(function() { return { 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/password\/partial\/reset-password-form" }; })]);jmId_30.directive("upSignupPassword", [(function() { return { 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/password\/partial\/signup-password" }; })]);var jmId_91;jmId_91 = angular.module("openId", ["happstackAuthentication"]);var jmId_92;tokenCB = (function(jmId_93) { alert(("tokenCB: " + jmId_93)); });jmId_91.controller("OpenIdCtrl", ["$scope", "$http", "$window", "$location", "userService", (function(jmId_94, jmId_95, jmId_96, jmId_97, jmId_98) { jmId_94.openIdRealm = { 'srOpenIdRealm': "" };jmId_94.openIdWindow = (function(jmId_99) { tokenCB = (function(jmId_100) { var jmId_101;jmId_101 = jmId_98.updateFromToken(jmId_100);jmId_94.isAuthenticated = jmId_101.isAuthenticated;jmId_94.$apply(); });jmId_92 = window.open(jmId_99, "_blank", "toolbar=0"); });jmId_94.setOpenIdRealm = (function(jmId_102) { var jmId_103;jmId_103 = (function(jmId_104, jmId_105, jmId_106, jmId_107) { if((jmId_104 == null)) { jmId_94.username_password_error = "error communicating with the server."; } else { if((jmId_104.jrStatus == "Ok")) { jmId_94.set_openid_realm_msg = "Realm Updated."; } else { jmId_94.set_open_id_realm_msg = jmId_104.jrData; }; }; });jmId_95.post(jmId_102, jmId_94.openIdRealm).success(jmId_103).error(jmId_103); }); })]);jmId_91.directive("openidYahoo", ["$rootScope", (function(jmId_108) { return { 'replace': true, 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/openId\/partial\/using-yahoo" }; })]);jmId_91.directive("openidRealm", ["$rootScope", (function(jmId_109) { return { 'restrict': "E", 'templateUrl': "\/authenticate\/auth\/authentication-methods\/openId\/partial\/realm" }; })]); })();