Skip to content

Instantly share code, notes, and snippets.

Trần Văn Luận luandevpro

Block or report user

Report or block luandevpro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.js
...
import { auth, providerGoogle } from '../lib/firebase';
function Index() {
...
const handleAuth = () => {
auth.signInWithPopup(providerGoogle).then((result) => {
console.log(result);
});
};
View index.js
...
import { auth, providerGoogle } from '../lib/firebase';
function Index() {
...
const handleAuth = () => {
auth.signInWithPopup(providerGoogle).then((result) => {
console.log(result);
});
};
View firebase.js
import firebase from 'firebase/app';
import 'firebase/auth';
import firebaseConfig from './firebaseConfig';
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig, {
timestampsInSnapshots: true,
});
}
View getUser.js
import withFirebase from '../../../middlewares/withFirebase';
async function handle(req, res) {
const token = req.cookies.token || req.headers.authorization;
if (token) {
req.admin
.auth()
.verifyIdToken(token)
.then((decodedToken) => {
console.log(decodedToken);
View getUser.js
import withFirebase from '../../../middlewares/withFirebase';
async function handle(req, res) {
const token = req.cookies.token || req.headers.authorization;
if (token) {
console.log(token, 'token');
res.status(200).json({ token });
} else {
res.status(400).json({ message: 'Not authorized! Go back!' });
}
View getUser.js
import withFirebase from '../../../middlewares/withFirebase';
async function handle(req, res) {
console.log(req.admin);
res.json({ user: 'Hello World' });
}
export default withFirebase(handle);
View withFirebase.js
import * as admin from 'firebase-admin';
const serviceAccount = require('./serviceAccountKey.json');
try {
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://nextjs-graphql-firebase-redux.firebaseio.com',
});
} catch (err) {
View getUser.js
async function handle(req, res) {
res.json({ user: 'Hello World' });
}
export default handle;
View package.json
{
...
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint components pages lib"
},
...
}
View create.js
import * as speakeasy from 'speakeasy';
import nodemailer from 'nodemailer';
export default async function handle(req, res) {
const result = JSON.parse(req.body);
const secret = await speakeasy.generateSecret({ length: 20 });
const token = await speakeasy.totp({
secret: secret.base32,
encoding: 'base32',
});
You can’t perform that action at this time.