Skip to content

Instantly share code, notes, and snippets.

Trần Văn Luận luandevpro

  • Viet Nam
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 getUser.js
import withFirebase from '../../../middlewares/withFirebase';
import cookies from '../../../middlewares/cookies';
async function handle(req, res) {
const token = req.cookies.token || req.headers.authorization.split(' ')[1];
if (token) {
req.admin
.auth()
.verifyIdToken(token)
.then((decodedIdToken) => {
View cookies.js
import { serialize } from 'cookie';
/**
* This sets `cookie` on `res` object
*/
const cookie = (res, name, value, options = {}) => {
const stringValue = typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value); // eslint-disable-line
if ('maxAge' in options) {
options.expires = new Date(Date.now() + options.maxAge); // eslint-disable-line
View getUser.js
import withFirebase from '../../../middlewares/withFirebase';
async function handle(req, res) {
const token = req.cookies.token || req.headers.authorization.split(' ')[1];
if (token) {
req.admin
.auth()
.verifyIdToken(token)
.then((decodedIdToken) => {
if (decodedIdToken) {
View getUser.js
import withFirebase from '../../../middlewares/withFirebase';
async function handle(req, res) {
const token = req.cookies.token || req.headers.authorization.split(' ')[1];
if (token) {
req.admin
.auth()
.verifyIdToken(token)
.then((decodedToken) => {
console.log(decodedToken);
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!' });
}
You can’t perform that action at this time.