web-server 注册、登录、获取服务器列表;game-server token 校验

This commit is contained in:
liangtongchuan
2020-08-19 14:40:11 +08:00
parent 0458817b51
commit 940879016f
32 changed files with 1144 additions and 38 deletions
@@ -1,3 +1,4 @@
import { UserModel } from './../../../db/User';
import {Application} from 'pinus';
import {FrontendSession} from 'pinus';
@@ -16,14 +17,24 @@ export class EntryHandler {
* @param {Object} msg request message
* @param {Object} session current session object
*/
async enter(msg: { rid: string, username: string }, session: FrontendSession) {
async enter(msg: { rid: string, username: string, token: string }, session: FrontendSession) {
let self = this;
let rid = msg.rid;
let uid = msg.username + '*' + rid;
let sessionService = self.app.get('sessionService');
let user = await UserModel.findUserByToken(msg.token);
if (!user) {
console.log('user token not found');
return {
code: 500,
error: true
};
}
// duplicate log in
if (!!sessionService.getByUid(uid)) {
console.log('uid not found');
return {
code: 500,
error: true