Permalink
Browse files

more auth fixes

  • Loading branch information...
1 parent 4ee9145 commit 86ad36ae4a35dcfb3021018801666c4d394e0eba iplk committed Oct 10, 2012
Showing with 45 additions and 34 deletions.
  1. +12 −6 web/assets/cslib/Users.coffee
  2. +2 −2 web/assets/css/custom.css
  3. +31 −26 web/assets/js/Users.js
@@ -6,17 +6,20 @@ usernameInput = $ "#usernameInput"
passwordInput = $ "#passwordInput"
form_login = $ "form_login"
+###
setCookie = (name, value) ->
c_value = escape value
c_name = escape name
document.cookie = "#{c_name}=#{c_value};"
console.log("Setting cookie to '#{c_name}=#{value};'")
console.log "Cookies is '#{document.cookie}'"
-
+###
+
getCookie = (name) ->
cookies = document.cookie.split(";")
console.log "cookies found #{cookies}"
for c in cookies
+ console.log("Cookie is #{c}")
cookie = c.split "="
if name == cookie[0]
return unescape cookie[1]
@@ -25,12 +28,15 @@ isAdmin = () ->
return getCookie("status") == "Admin"
setLogInControl = () ->
+ console.log("setLogInControl Called")
if isAdmin()
- adminMenu.css {display: "block"}
- loginMenu.css {display: "none"}
- else
- adminMenu.css {display: "none"}
- loginMenu.css {display: "block"}
+ console.log("Is an Admin")
+ adminMenu.css {display: "block"}
+ loginMenu.css {display: "none"}
+ else
+ console.log("Is a user")
+ adminMenu.css {display: "none"}
+ loginMenu.css {display: "block"}
### Old Testing controls
logoutButton.click ->
@@ -1,11 +1,11 @@
#adminMenu{
- display: "none"
+ display: none
}
#loginMenu{
- display: "none"
+ display: none
}
/* Fix for google maps */
View
@@ -1,5 +1,5 @@
(function() {
- var adminMenu, form_login, getCookie, isAdmin, loginButton, loginMenu, logoutButton, passwordInput, setCookie, setLogInControl, usernameInput;
+ var adminMenu, form_login, getCookie, isAdmin, loginButton, loginMenu, logoutButton, passwordInput, setLogInControl, usernameInput;
adminMenu = $("#adminMenu");
@@ -15,48 +15,53 @@
form_login = $("form_login");
- setCookie = function(name, value) {
- var c_name, c_value;
- c_value = escape(value);
- c_name = escape(name);
- document.cookie = "" + c_name + "=" + c_value + ";";
- console.log("Setting cookie to '" + c_name + "=" + value + ";'");
- return console.log("Cookies is '" + document.cookie + "'");
- };
+ /*
+ setCookie = (name, value) ->
+ c_value = escape value
+ c_name = escape name
+ document.cookie = "#{c_name}=#{c_value};"
+ console.log("Setting cookie to '#{c_name}=#{value};'")
+ console.log "Cookies is '#{document.cookie}'"
+ */
getCookie = function(name) {
var c, cookie, cookies, _i, _len;
cookies = document.cookie.split(";");
console.log("cookies found " + cookies);
for (_i = 0, _len = cookies.length; _i < _len; _i++) {
c = cookies[_i];
- cookie = c.split("=");
- if (name === cookie[0]) return unescape(cookie[1]);
+ console.log("Cookie is " + c);
}
+ cookie = c.split("=");
+ if (name === cookie[0]) return unescape(cookie[1]);
};
isAdmin = function() {
return getCookie("status") === "Admin";
};
setLogInControl = function() {
- if (isAdmin()) {
- adminMenu.css({
- display: "block"
- });
- return loginMenu.css({
- display: "none"
- });
- } else {
- adminMenu.css({
- display: "none"
- });
- return loginMenu.css({
- display: "block"
- });
- }
+ return console.log("setLogInControl Called");
};
+ if (isAdmin()) {
+ console.log("Is an Admin");
+ adminMenu.css({
+ display: "block"
+ });
+ loginMenu.css({
+ display: "none"
+ });
+ } else {
+ console.log("Is a user");
+ adminMenu.css({
+ display: "none"
+ });
+ loginMenu.css({
+ display: "block"
+ });
+ }
+
/* Old Testing controls
logoutButton.click ->
setCookie "status", "User"

0 comments on commit 86ad36a

Please sign in to comment.