var express = require('express');

/**
 * 登录
 * @param {express.request} request 请求
 * @param {express.response} response 响应
 */
function login(request, response) {
  response.end('eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOIiwiY29tcGFueUNvZGUiOiJjbG91ZHBsZXgiLCJvcmdhbml6YXRpb25Db2RlIjoiMSIsImV4cCI6MTYwODkwODM4M30.b_xJhlQ4iZzeCN2e7F1uNfQNOmjo_VLgSSHa2y6TmCZHxtlXZd_TEZH3VRp01qu7lNG7eFIEYtamSqLD5-W55g');
}

/**
 * 身份验证
 * @param {express.request} request 请求
 * @param {express.response} response 响应
 */
function isAuthenticated(request, response) {
  response.end('admin');
}

/**
 * 获取通行证
 * @param {express.request} request 请求
 * @param {express.response} response 响应
 */
function getPassport(request, response) {
  var result = {
    body: {
      id: null,
      account: 'admin',
      name: 'Admin',
      mobileNumber: '13800000002',
      identityCardNumber: 'admin@localhost',
      gender: null,
      email: null,
      avatarUrl: null,
      enabled: true,
      organizationCode: '1',
      companyCode: 'cloudplex',
      roles: []
    }
  };
  response.json(result.body).end();
}

module.exports = {
  'POST /api/passport/login': login,
  'GET /api/passport/authenticate': isAuthenticated,
  'GET /api/passport': getPassport
};
