firebaseoauth2
Advanced tools
Comparing version
38
index.js
@@ -531,2 +531,18 @@ const express = require("express"); | ||
const getUidtByAccessToken = (access_token) => { | ||
return new Promise(function(resolve, reject){ | ||
console.log('getClientByAccessToken', access_token) | ||
const ref = FirebaseDb.ref('/oAuth/tokens/AccessTokens/' + access_token).once('value') | ||
.then(function(snapshot){ | ||
if(snapshot.val()){ | ||
resolve(snapshot.val().uid) | ||
}else{ | ||
reject() | ||
} | ||
},function(){ | ||
reject() | ||
}) | ||
} | ||
} | ||
const getClientByRef = (ref) => { | ||
@@ -538,4 +554,2 @@ console.log('getClientByRef') | ||
if(snapshot.val()){ | ||
console.log(448, snapshot.val()) | ||
const value = snapshot.val() | ||
@@ -547,3 +561,2 @@ const uid = value.uid | ||
.then(function(client){ | ||
console.log(456, client) | ||
@@ -590,4 +603,23 @@ resolve({ | ||
// utility | ||
const getUserRecoad = (token) => { | ||
return new Promise(function(resolve, reject){ | ||
getUidtByAccessToken(token) | ||
.then(function(uid){ | ||
FirebaseAdmin.auth().getUser(uid) | ||
.tmen(function(userRecord){ | ||
resolve(userRecord) | ||
}, function(error){ | ||
reject(error) | ||
}) | ||
}) | ||
}) | ||
} | ||
const app.utility = { | ||
getUserRecoad : getUserRecoad | ||
} | ||
module.exports = { | ||
FirebaseOAuth2 : app | ||
} |
{ | ||
"name": "firebaseoauth2", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "indexjs.js", |
17530
4.52%552
5.75%