aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth-client.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/models/oauth-client.js
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
Diffstat (limited to 'server/models/oauth-client.js')
-rw-r--r--server/models/oauth-client.js62
1 files changed, 0 insertions, 62 deletions
diff --git a/server/models/oauth-client.js b/server/models/oauth-client.js
deleted file mode 100644
index 021a34007..000000000
--- a/server/models/oauth-client.js
+++ /dev/null
@@ -1,62 +0,0 @@
1'use strict'
2
3module.exports = function (sequelize, DataTypes) {
4 const OAuthClient = sequelize.define('OAuthClient',
5 {
6 clientId: {
7 type: DataTypes.STRING,
8 allowNull: false
9 },
10 clientSecret: {
11 type: DataTypes.STRING,
12 allowNull: false
13 },
14 grants: {
15 type: DataTypes.ARRAY(DataTypes.STRING)
16 },
17 redirectUris: {
18 type: DataTypes.ARRAY(DataTypes.STRING)
19 }
20 },
21 {
22 indexes: [
23 {
24 fields: [ 'clientId' ],
25 unique: true
26 },
27 {
28 fields: [ 'clientId', 'clientSecret' ],
29 unique: true
30 }
31 ],
32 classMethods: {
33 countTotal,
34 getByIdAndSecret,
35 loadFirstClient
36 }
37 }
38 )
39
40 return OAuthClient
41}
42
43// ---------------------------------------------------------------------------
44
45function countTotal (callback) {
46 return this.count().asCallback(callback)
47}
48
49function loadFirstClient (callback) {
50 return this.findOne().asCallback(callback)
51}
52
53function getByIdAndSecret (clientId, clientSecret) {
54 const query = {
55 where: {
56 clientId: clientId,
57 clientSecret: clientSecret
58 }
59 }
60
61 return this.findOne(query)
62}