mirror of https://github.com/status-im/codimd.git
parent
6e8ff98039
commit
cb1f263780
|
@ -9,7 +9,7 @@ import {URL} from "url";
|
|||
const githubAuth = Router()
|
||||
export = githubAuth
|
||||
|
||||
function githubUrl (path) {
|
||||
function githubUrl(path) {
|
||||
return config.github.enterpriseURL && new URL(path, config.github.enterpriseURL).toString()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {InternalOAuthError, Strategy} from "passport-oauth2";
|
||||
import config from "../../config";
|
||||
|
||||
export function parseProfile (data) {
|
||||
export function parseProfile(data) {
|
||||
const username = extractProfileAttribute(data, config.oauth2.userProfileUsernameAttr)
|
||||
const displayName = extractProfileAttribute(data, config.oauth2.userProfileDisplayNameAttr)
|
||||
const email = extractProfileAttribute(data, config.oauth2.userProfileEmailAttr)
|
||||
|
@ -20,7 +20,7 @@ export function parseProfile (data) {
|
|||
}
|
||||
}
|
||||
|
||||
export function extractProfileAttribute (data, path) {
|
||||
export function extractProfileAttribute(data, path) {
|
||||
if (!data) return undefined
|
||||
if (typeof path !== 'string') return undefined
|
||||
// can handle stuff like `attrs[0].name`
|
||||
|
@ -41,7 +41,8 @@ export function extractProfileAttribute (data, path) {
|
|||
|
||||
export class OAuth2CustomStrategy extends Strategy {
|
||||
private _userProfileURL: any;
|
||||
constructor (options, verify) {
|
||||
|
||||
constructor(options, verify) {
|
||||
options.customHeaders = options.customHeaders || {}
|
||||
super(options, verify)
|
||||
this.name = 'oauth2'
|
||||
|
@ -49,7 +50,7 @@ export class OAuth2CustomStrategy extends Strategy {
|
|||
this._oauth2.useAuthorizationHeaderforGET(true)
|
||||
}
|
||||
|
||||
userProfile (accessToken, done) {
|
||||
userProfile(accessToken, done) {
|
||||
this._oauth2.get(this._userProfileURL, accessToken, function (err, body, res) {
|
||||
if (err) {
|
||||
return done(new InternalOAuthError('Failed to fetch user profile', err))
|
||||
|
|
|
@ -71,7 +71,7 @@ export class Revision extends Model<RevisionAttributes> implements RevisionAttri
|
|||
length: number;
|
||||
patch: string;
|
||||
|
||||
public readonly createdAt ?:number
|
||||
public readonly createdAt ?: number
|
||||
|
||||
static initialize(sequelize: MySequelize): void {
|
||||
Revision.init({
|
||||
|
|
Loading…
Reference in New Issue