add game,home pages
This commit is contained in:
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+2
@@ -14,7 +14,9 @@ export class Account extends BaseController {
|
||||
async login() {
|
||||
try {
|
||||
const { body } = this.getRequestBody();
|
||||
console.log(body, 'body');
|
||||
const { userAccount, password } = body;
|
||||
console.log(userAccount, 'userAccount');
|
||||
const accountInfo: IAccountInfo = { userAccount, password };
|
||||
const result = await this.service.login(accountInfo);
|
||||
this.success(result);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Context, inject, controller, post, provide } from 'midway';
|
||||
import BaseController from '../../lib/baseController';
|
||||
import { IRoomService } from '../../interface/IRoom';
|
||||
|
||||
@provide()
|
||||
@controller('/node/game')
|
||||
export class GameController extends BaseController {
|
||||
|
||||
@inject()
|
||||
ctx: Context;
|
||||
|
||||
@inject('GameService')
|
||||
gameService: IGameService;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@post('/buyIn')
|
||||
async buyIn() {
|
||||
try {
|
||||
const result = await this.gameService.add();
|
||||
this.success(result);
|
||||
} catch (e) {
|
||||
this.fail('create room error');
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+5
-1
@@ -10,7 +10,11 @@ export default function auth(): any {
|
||||
const roomService = await app.applicationContext.getAsync('RoomService');
|
||||
const query = socket.handshake.query;
|
||||
// 用户信息
|
||||
const { room, userName } = query;
|
||||
const { room, token } = query;
|
||||
|
||||
const userInfo = app.jwt.verify(token);
|
||||
|
||||
const { userName } = userInfo;
|
||||
|
||||
// 检查房间是否存在,不存在则踢出用户
|
||||
// 备注:此处 app.redis 与插件无关,可用其他存储代替
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+2
-1
@@ -39,8 +39,9 @@ export default (appInfo: EggAppInfo) => {
|
||||
credentials: true,
|
||||
origin(ctx: Context) {
|
||||
const origin: string = ctx.get('origin');
|
||||
console.log(origin, 'orgin');
|
||||
// 允许*域名访问
|
||||
if (origin.indexOf('172.22.88.118') > -1) {
|
||||
if (origin.indexOf('http://172.22.72.70:8080') > -1) {
|
||||
console.log('come in');
|
||||
return origin;
|
||||
} else {
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+1
-1
@@ -1,5 +1,5 @@
|
||||
export interface IUser {
|
||||
nickName: string;
|
||||
nick_name: string;
|
||||
account: string;
|
||||
password?: string;
|
||||
}
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
+6
-6
@@ -1,5 +1,5 @@
|
||||
import { inject, Context } from 'midway';
|
||||
import { IRequestBody } from '../interface/IRequestBody';
|
||||
// import { IRequestBody } from '../interface/IRequestBody';
|
||||
import { IResult, ResultCode } from '../interface/IResult';
|
||||
|
||||
export default class BaseController {
|
||||
@@ -11,11 +11,11 @@ export default class BaseController {
|
||||
* 获取请求内容
|
||||
* @returns {IRequestBody}
|
||||
*/
|
||||
public getRequestBody(): IRequestBody {
|
||||
let params: IRequestBody;
|
||||
params = this.ctx.request.body.params && JSON.parse(this.ctx.request.body.params) || {};
|
||||
console.log(this.ctx.request.body, 'params');
|
||||
return params;
|
||||
public getRequestBody() {
|
||||
// let params: IRequestBody;
|
||||
// params = this.ctx.request.body.params && JSON.parse(this.ctx.request.body.params) || {};
|
||||
// console.log(this.ctx.request.body, 'params');
|
||||
return this.ctx.request;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Executable → Regular
Executable → Regular
+4
-2
@@ -71,8 +71,10 @@ export class AccountService extends BaseService implements IAccountService {
|
||||
return await this.user.findByAccount(userAccount);
|
||||
}
|
||||
|
||||
private getToken(userAccount: string) {
|
||||
const token = this.jwt.sign({ userAccount },
|
||||
private async getToken(userAccount: string) {
|
||||
const user = await this.user.findByAccount(userAccount);
|
||||
console.log(user, 'user----------');
|
||||
const token = this.jwt.sign({ userName: user.nick_name },
|
||||
this.jwtConfig.secret, { expiresIn: 60 * 60 });
|
||||
this.ctx.logger.info(`AccountService getToken token--${token}`);
|
||||
return token;
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Reference in New Issue
Block a user