protected override void OnExecute(Protocol.Login message, EC.ISession session, Interfaces.IUserAgent agent, Interfaces.ISiqiServer server) { Protocol.LoginResponse response = new Protocol.LoginResponse(); response.MsgID = message.MsgID; response.Success = false; try { Interfaces.Data.Model.User user = server.LoginHandler.Login(message.EMail, message.Password); if (user != null) { agent = server.GetUser(message.EMail); if (agent == null) { agent = new UserAgent(user, session); server.AddUser(agent); } else { agent.Session = session; } session[SESSION_KEY.USER] = agent; response.Tokey = message.EMail; response.Success = true; session.Channel.Status = Beetle.Express.ChannelStatus.security; } else { response.Message = "用户名和密码不正确!"; } } catch (Exception e_) { response.Message = e_.Message; } server.Send(response, session); }
public UserAgent(Interfaces.Data.Model.User user, EC.ISession session) { Name = user.Name; ID = user.ID; Session = session; }