mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00
added auth/utils.ts
Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
be65042792
commit
f550c5b1b2
1 changed files with 12 additions and 9 deletions
|
@ -1,11 +1,14 @@
|
||||||
'use strict'
|
import { User } from '../../models'
|
||||||
|
import { logger } from '../../logger'
|
||||||
|
|
||||||
const models = require('../../models')
|
exports.passportGeneralCallback = function callback (
|
||||||
const logger = require('../../logger')
|
accessToken,
|
||||||
|
refreshToken,
|
||||||
exports.passportGeneralCallback = function callback (accessToken, refreshToken, profile, done) {
|
profile,
|
||||||
var stringifiedProfile = JSON.stringify(profile)
|
done: (err: any, user: User | null) => void
|
||||||
models.User.findOrCreate({
|
): void {
|
||||||
|
const stringifiedProfile = JSON.stringify(profile)
|
||||||
|
User.findOrCreate({
|
||||||
where: {
|
where: {
|
||||||
profileid: profile.id.toString()
|
profileid: profile.id.toString()
|
||||||
},
|
},
|
||||||
|
@ -14,9 +17,9 @@ exports.passportGeneralCallback = function callback (accessToken, refreshToken,
|
||||||
accessToken: accessToken,
|
accessToken: accessToken,
|
||||||
refreshToken: refreshToken
|
refreshToken: refreshToken
|
||||||
}
|
}
|
||||||
}).spread(function (user, created) {
|
}).then(function ([user, _]) {
|
||||||
if (user) {
|
if (user) {
|
||||||
var needSave = false
|
let needSave = false
|
||||||
if (user.profile !== stringifiedProfile) {
|
if (user.profile !== stringifiedProfile) {
|
||||||
user.profile = stringifiedProfile
|
user.profile = stringifiedProfile
|
||||||
needSave = true
|
needSave = true
|
Loading…
Add table
Add a link
Reference in a new issue