本文整理汇总了TypeScript中firebase-token-generator.createToken函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createToken函数的具体用法?TypeScript createToken怎么用?TypeScript createToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createToken函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateUidAuthToken
export function generateUidAuthToken(secret, opts) {
opts = util.extend({ debug: false, admin: false }, opts);
var tokenGenerator = new FirebaseTokenGenerator(secret);
var uid = uuid.v4();
var token = tokenGenerator.createToken({ uid: uid }, opts);
return { uid: uid, token: token };
}
示例2: FirebaseTokenGenerator
UserModel.findOne(UserObject , (err , res )=>{
if(res){
var tokenGenerator = new FirebaseTokenGenerator("fmg2oEE1C1f7n4875ri5IucpBlnlt5oC3f3OyuPH");
var token = tokenGenerator.createToken({ uid: res.sid });
var result = { usertoken: token, user: res }
deferred.resolve(result);
}
else{
deferred.reject("Error occurred while saving user");
}
})
示例3: getAuthToken
export function getAuthToken(username, admin, simulate){
var FBTokenGenMod = require('firebase-token-generator');
var FBTokenGenerator = new FBTokenGenMod(FIREBASE_SECRET);
return FBTokenGenerator.createToken({ username: username }, {admin: admin, simulate:simulate});
}
示例4: require
import 'angular2-universal-polyfills';
import { bootstrap } from 'angular2-iot';
const FirebaseTokenGenerator = require('firebase-token-generator');
import { FirebasePrefix, FirebaseAuthToken } from './app/model/tokens';
import { SimonIotModule } from './app/simon-iot.module';
const {Board} = require('johnny-five');
const IO = require('raspi-io');
let firebaseToken = null;
if (process.env.FIREBASE_SECRET) {
const tokenGenerator = new FirebaseTokenGenerator(process.env.FIREBASE_SECRET);
firebaseToken = tokenGenerator.createToken({ uid: 'iot' }, { admin: true });
}
let board = new Board({
io: new IO(),
repl: false
});
board.on('ready', function () {
console.log('Starting Simon game...');
bootstrap(SimonIotModule, [
{ provide: FirebasePrefix, useValue: '/iot' },
{ provide: FirebaseAuthToken, useValue: firebaseToken }
]);
});