Skip to content

Commit 73a61b9

Browse files
committed
auth is mostly done
1 parent 170d8bd commit 73a61b9

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

api/auth.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ exports.is_authorized = function(req, res) {
5050
exports.login = function(req, res) {
5151
if (req.param("teamname") && req.param("password")) {
5252
authenticate(req, res, req.param("teamname"), req.param("password"), false, function(result) {
53-
if (!req.cookies.teamname)
54-
res.cookie("teamname", teamname);
55-
if (!req.cookies.password)
56-
res.cookie("password", common.encryptPass(password));
53+
if (result.success == 1) {
54+
if (!req.cookies.teamname && req.param("teamname"))
55+
res.cookie("teamname", req.param("teamname"));
56+
if (!req.cookies.password && req.param("password"))
57+
res.cookie("password", result.password);
58+
}
5759
res.send(result);
5860
return;
5961
})
@@ -166,7 +168,8 @@ var authenticate = function(req, res, teamname, password, isHash, callback) {
166168
req.session.tID = team._id.valueOf();
167169
callback({
168170
success: 1,
169-
message: "Logged in."
171+
message: "Logged in.",
172+
password: pwHash
170173
});
171174
return;
172175
} else {

web/js/dependencies.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,32 @@ function build_navbar (set) {
6969
function display_navbar () {
7070
var now = new Date();
7171
var during = startDate < now && endDate > now;
72+
73+
$.ajax({
74+
url: "/api/auth/loggedin",
75+
method: "GET",
76+
dataType: "json"
77+
}).done(function(data) {
78+
console.dir(data);
79+
build_navbar(2);
80+
if (data.success === 1) {
81+
$.ajax({
82+
url: "/api/auth/authorized",
83+
method: "GET",
84+
dataType: "json"
85+
}).done(function(data2) {
86+
if (data2.success === 1) {
87+
build_navbar(0);
88+
} else {
89+
build_navbar(3);
90+
}
91+
});
92+
} else {
93+
build_navbar(1);
94+
}
95+
});
96+
97+
/*
7298
$.ajax({
7399
url: "/api/auth/authorized",
74100
method: "GET",
@@ -118,6 +144,7 @@ function display_navbar () {
118144
});
119145
}
120146
});
147+
*/
121148
}
122149

123150
function load_footer() {

0 commit comments

Comments
 (0)