mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-10 22:48:38 +00: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')
|
||||
const logger = require('../../logger')
|
||||
|
||||
exports.passportGeneralCallback = function callback (accessToken, refreshToken, profile, done) {
|
||||
var stringifiedProfile = JSON.stringify(profile)
|
||||
models.User.findOrCreate({
|
||||
exports.passportGeneralCallback = function callback (
|
||||
accessToken,
|
||||
refreshToken,
|
||||
profile,
|
||||
done: (err: any, user: User | null) => void
|
||||
): void {
|
||||
const stringifiedProfile = JSON.stringify(profile)
|
||||
User.findOrCreate({
|
||||
where: {
|
||||
profileid: profile.id.toString()
|
||||
},
|
||||
|
@ -14,9 +17,9 @@ exports.passportGeneralCallback = function callback (accessToken, refreshToken,
|
|||
accessToken: accessToken,
|
||||
refreshToken: refreshToken
|
||||
}
|
||||
}).spread(function (user, created) {
|
||||
}).then(function ([user, _]) {
|
||||
if (user) {
|
||||
var needSave = false
|
||||
let needSave = false
|
||||
if (user.profile !== stringifiedProfile) {
|
||||
user.profile = stringifiedProfile
|
||||
needSave = true
|
Loading…
Add table
Reference in a new issue