瀏覽代碼

Moved identification to full name

Brendan Abolivier 8 年之前
父節點
當前提交
6872892cca
簽署人: Brendan Abolivier <contact@brendanabolivier.com> GPG 金鑰 ID: 8EF1500759F70623
共有 3 個檔案被更改,包括 6 行新增5 行删除
  1. 二進制
      auth/.server.js.swp
  2. 2
    1
      auth/form.html
  3. 4
    4
      auth/server.js

二進制
auth/.server.js.swp 查看文件


+ 2
- 1
auth/form.html 查看文件

5
         </head>
5
         </head>
6
         <body>
6
         <body>
7
                 <form method="post" action="">
7
                 <form method="post" action="">
8
-                        <input type="text" placeholder="username" name="username" />
8
+                        <input type="text" placeholder="first name" name="first" />
9
+                        <input type="text" placeholder="last name" name="last" />
9
                         <input type="submit" value="Log in" />
10
                         <input type="submit" value="Log in" />
10
                 </form>
11
                 </form>
11
         </body>
12
         </body>

+ 4
- 4
auth/server.js 查看文件

18
 });
18
 });
19
 
19
 
20
 app.post('/', function(req, res, next) {
20
 app.post('/', function(req, res, next) {
21
-	var identifier = req.body.username;
21
+	var identifier = req.body.first+';'+req.body.last;
22
 
22
 
23
 	var m = new MacaroonsBuilder(location, secretKey, identifier)
23
 	var m = new MacaroonsBuilder(location, secretKey, identifier)
24
 		.add_first_party_caveat("status = student")
24
 		.add_first_party_caveat("status = student")
26
 
26
 
27
 	res.cookie('das-macaroon', m.serialize());
27
 	res.cookie('das-macaroon', m.serialize());
28
 
28
 
29
-	res.send('Logged in as ' + req.body.username + ' (student)');
29
+	res.send('Logged in as ' + req.body.first + ' ' + req.body.last + ' (student)');
30
 });
30
 });
31
 
31
 
32
 app.get('/teacher', function(req, res, next) {
32
 app.get('/teacher', function(req, res, next) {
34
 });
34
 });
35
 
35
 
36
 app.post('/teacher', function(req, res, next) {
36
 app.post('/teacher', function(req, res, next) {
37
-	var identifier = req.body.username;
37
+	var identifier = req.body.first+';'+req.body.last;
38
 
38
 
39
 	var m = new MacaroonsBuilder(location, secretKey, identifier)
39
 	var m = new MacaroonsBuilder(location, secretKey, identifier)
40
 		.add_first_party_caveat("status = teacher")
40
 		.add_first_party_caveat("status = teacher")
42
 
42
 
43
 	res.cookie('das-macaroon', m.serialize());
43
 	res.cookie('das-macaroon', m.serialize());
44
 
44
 
45
-	res.send('Logged in as ' + req.body.username + ' (teacher)');
45
+	res.send('Logged in as ' + req.body.first + ' ' + req.body.last + ' (teacher)');
46
 });
46
 });
47
 
47
 
48
 app.listen(1337, function() {
48
 app.listen(1337, function() {