update
This commit is contained in:
@@ -1,41 +1,40 @@
|
||||
const { resp } = require("src/utils/response/index.js");
|
||||
const { get: getCacheInstance } = require("src/utils/cache.js");
|
||||
const sso = require("src/utils/sso/index.js");
|
||||
const { OPENID_EXPIRE } = require("src/constants/index.js");
|
||||
const uuid = require("uuid");
|
||||
const url = require("url");
|
||||
const { resp } = require('src/utils/response/index.js')
|
||||
const { get: getCacheInstance } = require('src/utils/cache.js')
|
||||
const sso = require('src/utils/sso/index.js')
|
||||
const uuid = require('uuid')
|
||||
const url = require('url')
|
||||
|
||||
const controller = {};
|
||||
module.exports = controller;
|
||||
const controller = {}
|
||||
module.exports = controller
|
||||
|
||||
controller.loginSSO = () => async (ctx) => {
|
||||
const { back_url: backURL } = ctx.query;
|
||||
const { back_url: backURL } = ctx.query
|
||||
|
||||
const state = uuid.v4();
|
||||
const state = uuid.v4()
|
||||
|
||||
const authURL = sso.getAuthURL(state);
|
||||
const authURL = sso.getAuthURL(state)
|
||||
|
||||
// store back url to cache
|
||||
const cacheKey = `login-${state}`;
|
||||
const cache = getCacheInstance();
|
||||
const cacheKey = `login-${state}`
|
||||
const cache = getCacheInstance()
|
||||
|
||||
cache.set(cacheKey, JSON.stringify({ back_url: backURL }), true);
|
||||
cache.set(cacheKey, JSON.stringify({ back_url: backURL }), true)
|
||||
|
||||
const u = new url.URL(authURL);
|
||||
const u = new url.URL(authURL)
|
||||
|
||||
ctx.resp(resp.Success, { url: u.toString() });
|
||||
};
|
||||
ctx.resp(resp.Success, { url: u.toString() })
|
||||
}
|
||||
|
||||
controller.logout = () => async (ctx) => {
|
||||
let link = "";
|
||||
let link = ''
|
||||
|
||||
if (ctx.token.sso) {
|
||||
link = sso.getLogoutURL();
|
||||
link = sso.getLogoutURL()
|
||||
}
|
||||
|
||||
ctx.resp(resp.Success, { url: link });
|
||||
};
|
||||
ctx.resp(resp.Success, { url: link })
|
||||
}
|
||||
|
||||
controller.getInfo = () => async (ctx) => {
|
||||
ctx.resp(resp.Success, {});
|
||||
};
|
||||
ctx.resp(resp.Success, {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user