-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.js
More file actions
67 lines (56 loc) · 1.61 KB
/
views.js
File metadata and controls
67 lines (56 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(function() {
var db = require("./db");
var crypto = require('crypto');
exports.index = function (req, res) {
res.render('index');
};
exports.setupClients = function (req, res) {
db.model.Client.find(function (err, clients) {
if (err) {
throw err;
} else {
res.render('setup-clients', { clients: clients });
}
});
};
exports.setupAddClient = function (req, res) {
res.render('setup-add-client');
};
exports.setupEditClient = function (req, res) {
var id = req.query['id'];
db.model.Client.findOne({_id: id}, function (err, client) {
if (err) {
throw err;
} else {
res.render('setup-edit-client', {oAuthClient: client });
}
});
};
exports.setupCreateClient = function (req, res) {
var name = req.body['name'];
// var redirectUrl = req.body['redirectUrl'];
var client = new db.model.Client();
client.name = name;
client.clientId = crypto.randomBytes(64).toString('hex');
client.clientSecret = crypto.randomBytes(64).toString('hex');
client.save(function (err, client) {
if (err) {
throw new err;
}
res.redirect("/setup/clients");
});
};
exports.setupModifyClient = function (req, res) {
var id = req.body['id'];
var name = req.body['name'];
db.model.Client.findOne({_id: id}, function (err, client) {
client.name = name;
client.save(function (err, client) {
if (err) {
throw new err;
}
res.redirect("/setup/clients");
});
});
};
}).call(this);