aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-03-21 21:11:26 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-03-21 21:11:26 +0100
commit37dc07b292ae4b24011a99146150869bb9c17c65 (patch)
tree07bd9ade440cc8dd07349a725ba7d38398628d94 /server/models
parent9457bf88079a23d28011ff7c65faa56a548b7817 (diff)
downloadPeerTube-37dc07b292ae4b24011a99146150869bb9c17c65.tar.gz
PeerTube-37dc07b292ae4b24011a99146150869bb9c17c65.tar.zst
PeerTube-37dc07b292ae4b24011a99146150869bb9c17c65.zip
Create an "installer" module that create defaults clients/users...
Diffstat (limited to 'server/models')
-rw-r--r--server/models/users.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/models/users.js b/server/models/users.js
index 355d991bd..367c206ab 100644
--- a/server/models/users.js
+++ b/server/models/users.js
@@ -34,8 +34,10 @@ const Users = {
34 createUser: createUser, 34 createUser: createUser,
35 getAccessToken: getAccessToken, 35 getAccessToken: getAccessToken,
36 getClient: getClient, 36 getClient: getClient,
37 getClients: getClients,
37 getRefreshToken: getRefreshToken, 38 getRefreshToken: getRefreshToken,
38 getUser: getUser, 39 getUser: getUser,
40 getUsers: getUsers,
39 saveToken: saveToken 41 saveToken: saveToken
40} 42}
41 43
@@ -70,6 +72,10 @@ function getClient (clientId, clientSecret) {
70 return OAuthClientsDB.findOne({ _id: mongo_id, clientSecret: clientSecret }) 72 return OAuthClientsDB.findOne({ _id: mongo_id, clientSecret: clientSecret })
71} 73}
72 74
75function getClients (callback) {
76 return OAuthClientsDB.find(callback)
77}
78
73function getRefreshToken (refreshToken) { 79function getRefreshToken (refreshToken) {
74 logger.debug('Getting RefreshToken (refreshToken: ' + refreshToken + ').') 80 logger.debug('Getting RefreshToken (refreshToken: ' + refreshToken + ').')
75 81
@@ -81,6 +87,10 @@ function getUser (username, password) {
81 return UsersDB.findOne({ username: username, password: password }) 87 return UsersDB.findOne({ username: username, password: password })
82} 88}
83 89
90function getUsers (callback) {
91 return UsersDB.find(callback)
92}
93
84function saveToken (token, client, user) { 94function saveToken (token, client, user) {
85 logger.debug('Saving token for client ' + client.id + ' and user ' + user.id + '.') 95 logger.debug('Saving token for client ' + client.id + ' and user ' + user.id + '.')
86 96