Пример #1
0
        public void Show()
        {
            var userRegistrationData = new UserRegistrationData();

            Console.WriteLine("Для создания нового профиля введите ваше имя:");
            userRegistrationData.FirstName = Console.ReadLine();

            Console.Write("Ваша фамилия:");
            userRegistrationData.LastName = Console.ReadLine();

            Console.Write("Пароль:");
            userRegistrationData.Password = Console.ReadLine();

            Console.Write("Почтовый адрес:");
            userRegistrationData.Email = Console.ReadLine();

            try
            {
                this.userService.Register(userRegistrationData);

                SuccessMessage.Show("Ваш профиль успешно создан. Теперь Вы можете войти в систему под своими учетными данными.");
            }

            catch (ArgumentNullException)
            {
                AlertMessage.Show("Введите корректное значение.");
            }

            catch (Exception)
            {
                AlertMessage.Show("Произошла ошибка при регистрации.");
            }
        }
        private static void Handle_RequestUserRegistration(int index, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            int    packetNum = buffer.ReadInteger();
            string msg       = buffer.ReadString();

            buffer.Dispose();

            //Json parse
            UserRegistrationData userData = JsonConvert.DeserializeObject <UserRegistrationData>(msg);

            //add your code you want to execute here;
            Console.WriteLine(index + " : Requested registration ({0}, {1}, {2})", userData.login, userData.password, userData.email);
            if (SqlConnection.RegisterUser(userData))
            {
                Console.WriteLine(index + ": Succesfully registered as " + userData.login);
                ServerTCP.Send_ConfirmUserRegistration(index);
                SqlConnection.SetDefaultUserImage(userData.login);
            }
            else
            {
                Console.WriteLine(index + ": Registration was aborted");
                ServerTCP.Send_AbortUserRegistration(index);
            }
        }
 private void RegisterUserButton()
 {
     if (IsDataComplete())
     {
         UserRegistrationData userRegistrationData = new UserRegistrationData(email, userName, pass);
         userRegistrationManager.OnTryCreateUser(userRegistrationData);
     }
 }
 private void LoginUserButton()
 {
     if (IsDataComplete())
     {
         UserRegistrationData userRegistrationData = new UserRegistrationData(email, userName, pass);
         userRegistrationData.autoLogin = autoLogin;
         userLoginManager.OnTryLoginUser(userRegistrationData);
     }
 }
Пример #5
0
 public void OnTryCreateUser(UserRegistrationData usRegData)
 {
     if (IsUserRegistrationDataComplete(usRegData))
     {
         GameSceneManager.Instance.SetActiveWaitForLoad(true);
         RegistrerNewUser(usRegData);
         OnUserRegistrationErrorMesage("REGISTRATION COMPLETE");
     }
 }
Пример #6
0
        public async Task <UserData> RegisterUser(UserRegistrationData registrationData)
        {
            var user = mapper.Map <User>(registrationData);
            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            return(mapper.Map <UserData>(user));
        }
Пример #7
0
        public void RegisterUser(UserRegistrationData userData)
        {
            var userRegistrationInput = new UserRegistrationInput()
            {
                UserName = userData.UserName,
                Password = userData.Password
            };

            _repository.AddUser(userRegistrationInput);
        }
Пример #8
0
 public async Task<ActionResult> Edit(UserRegistrationData form)
 {
     ApplicationUser user = await UserManager.FindByIdAsync(form.Id);
     if (user != null)
     {
         user.Email = form.Email;
         IdentityResult validEmail = await UserManager.UserValidator.ValidateAsync(user);
         if (!validEmail.Succeeded)
         {
             AddErrorsFromResult(validEmail);
         }
         IdentityResult validPass = null;
         if (form.Password != string.Empty)
         {
             validPass = await UserManager.PasswordValidator.ValidateAsync(form.Password);
             if (validPass.Succeeded)
             {
                 user.PasswordHash = UserManager.PasswordHasher.HashPassword(form.Password);
             }
             else
             {
                 AddErrorsFromResult(validPass);
             }
         }
         if ((validEmail.Succeeded && validPass == null) || (validEmail.Succeeded
         && form.Password != string.Empty && validPass.Succeeded))
         {
             user.Country = form.Country;
             user.City = form.City;
             user.IdentityNumber = form.IdentityNumber;
             user.Lastname = form.Lastname;
             user.Fistname = form.Fistname;
             user.Living = form.Living;
             user.PhoneNumber = form.PhoneNumber;
             user.Surname = form.Surname;
             user.Nationality = form.Nationality;
             IdentityResult result = await UserManager.UpdateAsync(user);
             if (result.Succeeded)
             {
                 return RedirectToAction("Index").WithSuccess("Your profile has been update successfully");
             }
             else
             {
                 AddErrorsFromResult(result);
             }
         }
     }
     else
     {
         ModelState.AddModelError("", "User Not Found");
     }
     return View(user);
    
 }
Пример #9
0
        public void Register(UserRegistrationData userRegistrationData)
        {
            if (String.IsNullOrEmpty(userRegistrationData.FirstName))
            {
                throw new ArgumentNullException();
            }

            if (String.IsNullOrEmpty(userRegistrationData.LastName))
            {
                throw new ArgumentNullException();
            }

            if (String.IsNullOrEmpty(userRegistrationData.Password))
            {
                throw new ArgumentNullException();
            }

            if (String.IsNullOrEmpty(userRegistrationData.Email))
            {
                throw new ArgumentNullException();
            }

            if (userRegistrationData.Password.Length < 8)
            {
                throw new ArgumentNullException();
            }

            if (!new EmailAddressAttribute().IsValid(userRegistrationData.Email))
            {
                throw new ArgumentNullException();
            }

            if (userRepository.FindByEmail(userRegistrationData.Email) != null)
            {
                throw new ArgumentNullException();
            }



            var userEntity = new UserEntity()
            {
                firstname = userRegistrationData.FirstName,
                lastname  = userRegistrationData.LastName,
                password  = userRegistrationData.Password,
                email     = userRegistrationData.Email,
            };

            if (this.userRepository.Create(userEntity) == 0)
            {
                throw new Exception();
            }
        }
Пример #10
0
        public IActionResult Post([FromBody] UserRegistrationData userRegistrationData)
        {
            if (_dbContext.Users.Any(ue => ue.Login == userRegistrationData.Login))
            {
                return(new StatusCodeResult(409));
            }

            var userEntity = userRegistrationData.ToUserEntity(_dbContext);

            _dbContext.Users.Add(userEntity);
            _dbContext.SaveChanges();
            return(Ok(new { userId = userEntity.Id }));
        }
Пример #11
0
    private async void RegistrerNewUser(UserRegistrationData usRegData)
    {
        fbUserRegistration = new FbUserRegistration();
        string             macAddres = HelperUserData.GetMacAddress();
        string             localIP   = HelperUserData.GetLocalIPAddress();
        HashWithSaltResult hashSalt  = HelperUserData.HashWithSalt(usRegData.Pass, 32, new SHA256Managed());
        string             pSalt     = hashSalt.Salt;
        string             hasPass   = hashSalt.Digest;
        UserDB             userDB    = new UserDB(usRegData.UserName, macAddres, pSalt, hasPass);
        await fbUserRegistration.CreateNewUser(userDB, usRegData.Pass, usRegData.Email, OnUserRegistrationErrorMesage);

        GameSceneManager.Instance.SetActiveWaitForLoad(false);
    }
Пример #12
0
        public void Register(UserRegistrationData regData)
        {
            if (string.IsNullOrEmpty(regData.FirstName))
            {
                throw new ArgumentNullException();
            }

            if (string.IsNullOrEmpty(regData.LastName))
            {
                throw new ArgumentNullException();
            }

            if (string.IsNullOrEmpty(regData.Password))
            {
                throw new ArgumentNullException();
            }

            if (string.IsNullOrEmpty(regData.Email))
            {
                throw new ArgumentNullException();
            }

            if (regData.Password.Length < 8)
            {
                throw new ArgumentNullException();
            }

            if (!new EmailAddressAttribute().IsValid(regData.Email))
            {
                throw new ArgumentNullException();
            }

            if (userRepo.FindByEmail(regData.Email) != null)
            {
                throw new ArgumentNullException();
            }

            var user = new UserEntity()
            {
                firstname = regData.FirstName,
                lastname  = regData.LastName,
                password  = regData.Password,
                email     = regData.Email
            };

            if (userRepo.Create(user) == 0)
            {
                throw new Exception();
            }
        }
Пример #13
0
 protected void SubmitHandler(object sender, EventArgs e)
 {
     try {
         var userData = new UserRegistrationData()
         {
             UserName = UserName.Text, Password = Password.Text
         };
         AuthService.RegisterUser(userData);
         isRegisterSuccess = true;
     } catch (DuplicateNameException) {
         UserNameDuplicationValidation.IsValid = false;
     } catch (Exception) {
         didRegistrationErrorHappen = true;
     }
 }
Пример #14
0
        public void RegisterUser__TwoUsers()
        {
            var userData2 = new UserRegistrationData()
            {
                UserName = "******", Password = "******"
            };

            _authService.RegisterUser(userData);
            _authService.RegisterUser(userData2);
            var user1 = _repository.GetUserByName(userData.UserName);
            var user2 = _repository.GetUserByName(userData2.UserName);

            Assert.AreEqual(userData.UserName, user1.Name);
            Assert.AreEqual(userData2.UserName, user2.Name);
            Assert.AreEqual(2, _repository.UserCount);
        }
Пример #15
0
        static void Main(string[] args)
        {
            Console.WriteLine("Добро пожаловать в социальную сеть.");

            while (true)
            {
                Console.WriteLine("Для регистрации пользователя введите имя пользователя:");

                string firstName = Console.ReadLine();

                Console.Write("фамилия:");
                string lastName = Console.ReadLine();

                Console.Write("пароль:");
                string password = Console.ReadLine();

                Console.Write("почтовый адрес:");
                string email = Console.ReadLine();

                UserRegistrationData userRegistrationData = new UserRegistrationData()
                {
                    FirstName = firstName,
                    LastName  = lastName,
                    Password  = password,
                    Email     = email
                };

                try
                {
                    userService.Register(userRegistrationData);
                    Console.WriteLine("Регистрация произошла успешно!");
                }

                catch (ArgumentNullException)
                {
                    Console.WriteLine("Введите корректное значение.");
                }

                catch (Exception)
                {
                    Console.WriteLine("Произошла ошибка при регистрации.");
                }

                Console.ReadLine();
            }
        }
Пример #16
0
 private bool IsUserRegistrationDataComplete(UserRegistrationData usRegData)
 {
     // CHEQUEAR QUE EL NOMBRE TENGA MAS DE UNA CANTIDAD DETERMINADA DE CARACTERES
     // CHEQUEAR SI HAY ALGUN CARACTER QUE NO SE PERMITE
     // CHEQUEAR QUE NO SEA UN NOMBRE OFENSIVO DE USUARIO
     if (usRegData.UserName.Length < 8)
     {
         OnUserRegistrationErrorMesage?.Invoke("Your name is to short, must be at least  8 characters long");
         return(false);
     }
     if (usRegData.Pass.Length < 6)
     {
         OnUserRegistrationErrorMesage?.Invoke("Your name is to short, must be at least  8 characters long");
         return(false);
     }
     return(true);
 }
Пример #17
0
        public static bool RegisterUser(UserRegistrationData userData)
        {
            if (ValidLogin(userData.login) && ValidEmail(userData.email))
            {
                string query = string.Format("INSERT INTO gamedata(login, password, email) VALUES('{0}','{1}','{2}')", userData.login, userData.password, userData.email);
                Console.WriteLine(query);
                try {
                    MySqlCommand cmd = new MySqlCommand(query, sqlConnection);
                    sqlConnection.Open();
                    cmd.ExecuteNonQuery();
                    sqlConnection.Close();
                    Console.WriteLine("New user joined: " + userData.login);

                    string[] newChars;
                    switch (userData.faction)
                    {
                    case "Faith":
                        newChars = new string[] { "Preacher", "Paladin", "Priest" };
                        break;

                    default:
                        newChars = new string[] { "Preacher", "Paladin", "Priest" };
                        break;
                    }

                    string newUserId = settings["subIndex"] + "-" + GenerateUserId();

                    InitializeUserAccountData(userData.login, newUserId, newChars);

                    InitializeUserChar(newChars[0], newUserId);
                    InitializeUserChar(newChars[1], newUserId);
                    InitializeUserChar(newChars[2], newUserId);

                    return(true);
                } catch (System.Exception ex) {
                    Console.WriteLine(ex);
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("Login or Email are already registered.");
                return(false);
            }
        }
Пример #18
0
        public async Task <UserRegistrationResult> TryRegisterUser(UserRegistrationData registrationData)
        {
            var userData = await userRepository.GetUser(registrationData.ExternalId);

            if (userData == null)
            {
                userData = await userRepository.RegisterUser(registrationData);

                await userRepository.SaveGoogleMap(userData, registrationData.ExternalId);

                return(new UserRegistrationResult {
                    NewUserRegistered = true, UserData = userData
                });
            }
            return(new UserRegistrationResult {
                UserData = userData
            });
        }
        public async Task <LoginServerReturnData> RegisterUserAsync(string email, string password, string confirmPassword)
        {
            var returnValue = new LoginServerReturnData();
            var client      = new HttpClient();

            var model = new UserRegistrationData
            {
                Email           = email,
                Password        = password,
                ConfirmPassword = confirmPassword
            };

            var         json        = JsonConvert.SerializeObject(model);
            HttpContent httpContent = new StringContent(json);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                response = await client.PostAsync(
                    "https://sit313apiserver.azurewebsites.net/api/Account/Register", httpContent);
            }
            catch (Exception ex)
            {
                returnValue.SuccessStatus = false;
                returnValue.ErrorMessage  = ex.ToString();
                return(returnValue);
            }

            returnValue.SuccessStatus = response.IsSuccessStatusCode;
            if (!returnValue.SuccessStatus)
            {
                returnValue.ErrorMessage = response.ReasonPhrase;
            }

            return(returnValue);
        }
    private async void LoginUser(UserRegistrationData usRegData)
    {
        fbUserLogin = new FbUserLogin();
        UserDB logedUser = await fbUserLogin.UserLoginMultipleInterface(usRegData.UserName, OnUserLoginErrorMesage, usRegData.Pass, usRegData.Email);

        if (logedUser == null)
        {
            Debug.Log("Logged User NULL");
            GameSceneManager.Instance.SetActiveWaitForLoad(false);
            return;
        }
        ConfigurationData configurationData = new ConfigurationData();

        configurationData.user      = logedUser;
        configurationData.autoLogin = usRegData.autoLogin;
        configurationData.email     = usRegData.Email;
        configurationData.password  = usRegData.Pass;

        helperCardCollectionJsonKimboko = new HelperCardCollectionJsonKimboko();
        helperCardCollectionJsonKimboko.SetConfigurationDataToJson(configurationData);

        GameSceneManager.Instance.SetActiveWaitForLoad(false);
        GameSceneManager.Instance.LoadSceneAsync(GameSceneManager.GAMESCENE.MAINMENU);
    }
 public void OnTryLoginUser(UserRegistrationData usRegData)
 {
     GameSceneManager.Instance.SetActiveWaitForLoad(true);
     LoginUser(usRegData);
 }
Пример #22
0
        static void Main(string[] args)
        {
            Console.WriteLine("Добро пожаловать в социальную сеть.");

            while (true)
            {
                Console.WriteLine("Войти в профиль (нажмите 1)");
                Console.WriteLine("Зарегистрироваться (нажмите 2)");

                switch (Console.ReadLine())
                {
                case "1":
                {
                    var authenticationData = new UserAuthenticationData();

                    Console.WriteLine("Введите почтовый адрес:");
                    authenticationData.Email = Console.ReadLine();

                    Console.WriteLine("Введите пароль:");
                    authenticationData.Password = Console.ReadLine();

                    try
                    {
                        User user = userService.Authenticate(authenticationData);

                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Вы успешно вошли в социальную сеть! Добро пожаловать {0}", user.FirstName);
                        Console.ForegroundColor = ConsoleColor.White;


                        while (true)
                        {
                            Console.WriteLine("Просмотреть информацию о моём профиле (нажмите 1)");
                            Console.WriteLine("Редактировать мой профиль (нажмите 2)");
                            Console.WriteLine("Добавить в друзья (нажмите 3)");
                            Console.WriteLine("Написать сообщение (нажмите 4)");
                            Console.WriteLine("Выйти из профиля (нажмите 5)");

                            switch (Console.ReadLine())
                            {
                            case "1":
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("Информация о моем профиле");
                                Console.WriteLine("Мой идентификатор: {0}", user.Id);
                                Console.WriteLine("Меня зовут: {0}", user.FirstName);
                                Console.WriteLine("Моя фамилия: {0}", user.LastName);
                                Console.WriteLine("Мой пароль: {0}", user.Password);
                                Console.WriteLine("Мой почтовый адрес: {0}", user.Email);
                                Console.WriteLine("Ссылка на моё фото: {0}", user.Photo);
                                Console.WriteLine("Мой любимый фильм: {0}", user.FavoriteMovie);
                                Console.WriteLine("Моя любимая книга: {0}", user.FavoriteBook);
                                Console.ForegroundColor = ConsoleColor.White;
                                break;
                            }

                            case "2":
                            {
                                Console.Write("Меня зовут:");
                                user.FirstName = Console.ReadLine();

                                Console.Write("Моя фамилия:");
                                user.LastName = Console.ReadLine();

                                Console.Write("Ссылка на моё фото:");
                                user.Photo = Console.ReadLine();

                                Console.Write("Мой любимый фильм:");
                                user.FavoriteMovie = Console.ReadLine();

                                Console.Write("Моя любимая книга:");
                                user.FavoriteBook = Console.ReadLine();

                                userService.Update(user);

                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("Ваш профиль успешно обновлён!");
                                Console.ForegroundColor = ConsoleColor.White;

                                break;
                            }
                            }
                        }
                    }

                    catch (WrongPasswordException)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Пароль не корректный!");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    catch (UserNotFoundException)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Пользователь не найден!");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    break;
                }

                case "2":
                {
                    var userRegistrationData = new UserRegistrationData();

                    Console.WriteLine("Для создания нового профиля введите ваше имя:");
                    userRegistrationData.FirstName = Console.ReadLine();

                    Console.Write("Ваша фамилия:");
                    userRegistrationData.LastName = Console.ReadLine();

                    Console.Write("Пароль:");
                    userRegistrationData.Password = Console.ReadLine();

                    Console.Write("Почтовый адрес:");
                    userRegistrationData.Email = Console.ReadLine();

                    try
                    {
                        userService.Register(userRegistrationData);

                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Ваш профиль успешно создан. Теперь Вы можете войти в систему под своими учетными данными.");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    catch (ArgumentNullException)
                    {
                        Console.WriteLine("Введите корректное значение.");
                    }

                    catch (Exception)
                    {
                        Console.WriteLine("Произошла ошибка при регистрации.");
                    }

                    break;
                }
                }
            }
        }