12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 'use strict';
- /**
- * 登录页面控制器
- *
- * @author CaiAoLin
- * @date 2017/11/15
- * @version
- */
- const SSO = require('../lib/sso');
- module.exports = app => {
- class LoginController extends app.BaseController {
- /**
- * 登录页面
- *
- * @param {Object} ctx - egg全局页面
- * @return {void}
- */
- async index(ctx) {
- const renderData = {};
- await ctx.render('login/login.ejs', renderData);
- }
- /**
- * 登录操作
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- async login(ctx) {
- const username = ctx.request.body.username;
- const password = ctx.request.body.password;
- try {
- const sso = new SSO(ctx);
- const result = await sso.loginValid(username, password);
- } catch (error) {
- console.log(error);
- }
- ctx.body = 'success';
- }
- }
- return LoginController;
- };
|