You've already forked KF-MMO-Server
refactor
This commit is contained in:
21
Account/_login.ts
Normal file
21
Account/_login.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { userData } from "../Classes/userData";
|
||||
import { players } from "../Player/players";
|
||||
import { emitLogin } from "./_emitLogin";
|
||||
import { users } from "./users";
|
||||
|
||||
export function login(socket, data){
|
||||
let buff = Buffer.from(data, 'base64');
|
||||
let json : userData = JSON.parse(buff.toString('utf-8'));
|
||||
if (!json.login || !json.password) return
|
||||
|
||||
let result = users.readUser(json.login, json.password);
|
||||
let player = null
|
||||
if(result != null){
|
||||
player = players.readPlayer(result.id)
|
||||
if(player == null){
|
||||
player = players.createPlayer(result.id)
|
||||
}
|
||||
}
|
||||
|
||||
emitLogin(socket, result, player);
|
||||
}
|
||||
Reference in New Issue
Block a user