func (server *Server) tryInscription(u *user.User, message string) { socket := *u.Socket request := user.GetRegisterRequest(message) inscriptionOk, loginOk, passwordOk := user.InscriptionSite(request.Login, request.Password, request.VerifPassword, request.Mail) reply := user.RegisterReply{inscriptionOk, loginOk, passwordOk, request.Login, u.GravatarLink, server.roomList.GetRoomsTab()} socket.Emit("register", reply.String()) if inscriptionOk { u.Login = request.Login u.Mail = request.Mail u.CreateGravatarLink() server.changeUserRoom(u, constants.DefaultRoom) } }
// tryLoginUser try to login user func (server *Server) tryLoginUser(u *user.User, message string) { socket := *u.Socket request := user.GetLoginRequest(message) login, password, newUser := user.ConnectSite(request.Login, request.Password) success := login && password reply := user.LoginReply{success, login, password, request.Login, server.roomList.GetRoomsTab(), u.GravatarLink} socket.Emit("login", reply.String()) if success { u.Login = newUser.Login u.Mail = newUser.Mail u.CreateGravatarLink() server.changeUserRoom(u, constants.DefaultRoom) logger.Print("Connexion d'un utilisateur") } }