firebaseoauth2
Advanced tools
Comparing version
74
index.js
@@ -33,2 +33,3 @@ const express = require("express"); | ||
console.log('Build in Client ID', BuildinClientID) | ||
console.log('Build in Client Secret', BuildinClientSecret) | ||
@@ -136,41 +137,2 @@ res.json({ message: "ok" }); | ||
// Buildin Client ならば、自動的にClientを追加する | ||
const setBuildinClient = (uid, client_id, scope, redirect_uri) => { | ||
console.log('setBuildinClient'); | ||
return new Promise(function(resolve, reject){ | ||
if(client_id == BuildinClientID){ | ||
FirebaseDb.ref('/oAuth/users/' + uid + '/' + client_id).set({ | ||
scope : scope, | ||
redirect_uri : redirect_uri, | ||
client_secret : BuildinClientSecret | ||
}, function(error){ | ||
resolve() | ||
}) | ||
}else{ | ||
resolve() | ||
} | ||
}) | ||
} | ||
// 指定したクライアントのAuthorizeCodeを更新する | ||
const updateAuthorizeCode = (uid, client_id) => { | ||
return new Promise(function(resolve, reject){ | ||
let clientRef = FirebaseDb.ref('/oAuth/users/' + uid + '/' + client_id) | ||
clientRef.once('value') | ||
.then(function(snapshot){ | ||
if(snapshot.val()){ | ||
let authorize_code = nanoid(); | ||
clientRef.update({ | ||
authorize_code: authorize_code | ||
},function(error){ | ||
resolve(authorize_code) | ||
}) | ||
}else{ | ||
reject() | ||
} | ||
}) | ||
}) | ||
} | ||
app.post("/oauth/accesstoken**", (req, res) => { | ||
@@ -202,3 +164,37 @@ console.log("/oauth/accesstoken") | ||
// Buildin Client ならば、自動的にClientを追加する | ||
const setBuildinClient = (uid, client_id, scope, redirect_uri) => { | ||
console.log('setBuildinClient'); | ||
return new Promise(function(resolve, reject){ | ||
if(client_id == BuildinClientID){ | ||
FirebaseDb.ref('/oAuth/users/' + uid + '/' + client_id).set({ | ||
scope : scope, | ||
redirect_uri : redirect_uri, | ||
client_secret : BuildinClientSecret | ||
}, function(error){ | ||
resolve() | ||
}) | ||
}else{ | ||
resolve() | ||
} | ||
}) | ||
} | ||
// 指定したクライアントのAuthorizeCodeを更新する | ||
const updateAuthorizeCode = (uid, client_id) => { | ||
return new Promise(function(resolve, reject){ | ||
if(uid && client_id){ | ||
let authorize_code = nanoid(); | ||
let clientRef = FirebaseDb.ref('/oAuth/AuthorizeCodes/' + authorize_code).set({ | ||
uid : uid | ||
client_id : client_id | ||
}, function(error){ | ||
resolve(authorize_code) | ||
return | ||
}) | ||
}else{ | ||
reject() | ||
} | ||
}) | ||
} | ||
@@ -205,0 +201,0 @@ |
{ | ||
"name": "firebaseoauth2", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "indexjs.js", |
5567
-0.34%170
-0.58%