import { Post , Prefix , Get } from "egg-shell-decorators" ; import BaseController from "./base" ; @ Prefix ( "user" ) export default class UserController extends BaseController { author : Cookie
       *  description @ Get ( "/getTokenByApp" ) public async getTokenByApplications ( { request : { query : { code } , } , } ) { const { ctx , app } = this ; const userToken = await ctx . service . user . getTokenByApplications ( { code } ) ; const userInfo = await ctx . service . user . getUserInfo ( { access_token : userToken . access_token , } ) ; ctx . service . user . saveUser ( { userInfo , } ) ; const token = app . jwt . sign ( { userToken , userInfo , } , app . config . jwt . secret ) ; ctx . set ( { "Access-Control-Expose-Headers" : "authorization" } ) ; ctx . set ( { authorization : token } ) ; ctx . cookies . set ( 'authorization' , token , { maxAge : 1000 * 3600 * 24 , httpOnly : true , domain : '.cookieboty.com' } ) ; ctx . redirect ( `http://fe.cookieboty.com` ) ; } author : Cookie
     *  description @ Post ( "/getUserToken" ) public async getUserToken ( { request : { body : { params } , } , } ) { const { ctx , app } = this ; const { username , password } = params ; const userToken = await ctx . service . user . getUserToken ( { username , password , } ) ; const userInfo = await ctx . service . user . getUserInfo ( { access_token : userToken . access_token , } ) ; ctx . service . user . saveUser ( { userInfo , } ) ; const token = app . jwt . sign ( { userToken , userInfo , } , app . config . jwt . secret ) ; ctx . set ( { "Access-Control-Expose-Headers" : "authorization" } ) ; ctx . set ( { authorization : token } ) ; this . success ( userInfo ) ; } author : Cookie
     *  description @ Get ( "/getUserInfo" ) public async getUserInfo ( { request : { body : { params } , } , } ) { const { ctx } = this ; const { access_token } = this . user ; const userInfo = await ctx . service . user . getUserInfo ( { access_token , } ) ; this . success ( userInfo ) ; } }