Пример #1
0
        public ActionResult <CreateUserRequest> CreateUser([FromBody] CreateUserRequest newUserObject)
        {
            newUserObject.FireBaseUid = UserId;
            if (!_validator.Validate(newUserObject))
            {
                return(BadRequest(new { error = "NESVault User Object Validation Failed " }));
            }

            var newUser = _repo.AddNewUser(newUserObject);

            return(Ok(newUser));
        }
Пример #2
0
 public static Player InsertUser(string username, string password, string screenName)
 {
     try
     {
         int userID = UsersRepository.AddNewUser(username, password, screenName);
         if (userID == -1)//username already exists
         {
             return(null);
         }
         return(new Player(userID, screenName));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
        private void HandleLoginMsg(Login login, TalkBackDBContext dbContext)
        {
            UsersRepository repo = new UsersRepository(dbContext);

            // check if User Exists:
            if (repo.IsUserExist(login.Name))
            {
                // check password:
                if (!repo.IsPasswordCorrect(login.Name, login.Password))
                {
                    LoginResponse response = new LoginResponse {
                        Success = false, ErrorMessage = "Wrong password, please try again"
                    };
                    WebSocketMiddleware.SendStringAsync(_webSocket, response.ToXml().ToString());
                    return;
                }
            }
            else
            {
                // new user: add it to repo
                repo.AddNewUser(new UserModel {
                    Name = login.Name, Password = login.Password
                });
            }

            // login successfully:
            // 1. record UserName for this handler
            UserName = login.Name;
            // 2. add to the websocket dictionary
            WebSocketMiddleware._sockets.TryAdd(UserName, _webSocket);
            // 3. inform all online users about the new/updated contact,
            //    create a Set<string> of online users:
            ISet <string> online = new HashSet <string>();
            Contact       me     = new Contact {
                Name = UserName, IsOnline = true
            };
            string contactUpdate = me.ToXml().ToString();

            online = Broadcast(contactUpdate);
            // 4. send the client the list of contacts:
            IList <AbstractXmlSerializable> contacts = repo.GetContactsList(UserName, online);
            string contactsList = ModelXmlMapper.GetAsXmlString(contacts);

            WebSocketMiddleware.SendStringAsync(_webSocket, contactsList);
        }
Пример #4
0
 public ActionResult Registry(Users user, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         var data = _userRepository.AddNewUser(user);
         if (data.Succeed)
         {
             ModelState.Clear();
             ViewBag.SuccessMsg        = "Konto zostało utworzone!";
             SessionPresister.UserName = user?.Name;
             SessionPresister.UserId   = user.Id;
             return(new RedirectResult(returnUrl));
         }
         else
         {
             ViewBag.ErrorMsg = "Wystąpił błąd podczas utworzenia konta. Podany login bądź email już istnieje!";
         }
     }
     return(View("Index"));
 }
Пример #5
0
 public int Post([FromBody] string name)
 {
     return(_usersRepository.AddNewUser(name));
 }
Пример #6
0
 public bool Post([FromBody] object input)
 {
     return(_repo.AddNewUser(input));
 }