public async Task <string> SignUpAsync(User user)
        {
            if (string.IsNullOrEmpty(user.Email) || string.IsNullOrEmpty(user.FirstName) ||
                string.IsNullOrEmpty(user.LastName) || string.IsNullOrEmpty(user.Password))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (user.Password.Length < 6 || user.Password.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            user.Email = user.Email.ToLower();

            var isItAUser = GlobalVariables.databaseConnection.GetUserByEmail(user.Email);

            if (isItAUser is null || string.IsNullOrEmpty(isItAUser.Email))
            {
                GlobalVariables.InitializeGlobalCasualImage();

                user.ProfilePicture = GlobalVariables.GlobalCasualImage;
                user.Password       = new Segédfüggvények().EncryptPassword(user.Password);

                var success = GlobalVariables.databaseConnection.AddUser(user);

                if (success)
                {
                    return(English.Empty());
                }
            }
        //1:üres mind a kettő
        //2:első üres
        //3:második üres
        //4:nem jó az email formátuma
        //5:a pw nem olyan hosszban van 6-16
        //6:nem található ilyen email a DBben vagy rossz a jelszó
        //7:minden jó
        public string Login(string EMAIL, string PASSWORD)
        {
            if (String.IsNullOrEmpty(EMAIL) && String.IsNullOrEmpty(PASSWORD))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (String.IsNullOrEmpty(EMAIL))
            {
                return(English.EmailIsEmpty());
            }
            if (String.IsNullOrEmpty(PASSWORD))
            {
                return(English.PasswordIsEmpty());
            }
            if (!segédfüggvények.IsValidEmailAddress(EMAIL.ToLower()))
            {
                return(English.BadEmailFormat());
            }
            if (PASSWORD.Length < 6 || PASSWORD.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            var user = DependencyService.Get <IDBAccess.IBlobStorage>().GetUserByEmail(EMAIL.ToLower());

            if (user is null || user.Password != PASSWORD)
            {
                return(English.BadPasswordOrEmail());
            }

            return(English.Empty());
        }
        //1:üres mind a kettő
        //2:első üres
        //3:második üres
        //4:nem jó az email formátuma
        //5:a pw nem olyan hosszban van 6-16
        //6:nem található ilyen email a DBben vagy rossz a jelszó
        //7:minden jó
        public string Login(string EMAIL, string PASSWORD)
        {
            if (String.IsNullOrEmpty(EMAIL) && String.IsNullOrEmpty(PASSWORD))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (String.IsNullOrEmpty(EMAIL))
            {
                return(English.EmailIsEmpty());
            }
            if (String.IsNullOrEmpty(PASSWORD))
            {
                return(English.PasswordIsEmpty());
            }
            if (!segédfüggvények.IsValidEmailAddress(EMAIL.ToLower()))
            {
                return(English.BadEmailFormat());
            }
            if (PASSWORD.Length < 6 || PASSWORD.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            var user = GlobalVariables.databaseConnection.GetUserByEmail(EMAIL.ToLower());

            if (user is null || user.Password != segédfüggvények.EncryptPassword(PASSWORD))
            {
                return(English.BadPasswordOrEmail());
            }

            return(English.Empty());
        }
Beispiel #4
0
        public string UpdatePassword(string oldpassword, string newPassword)
        {
            if (string.IsNullOrEmpty(oldpassword) || string.IsNullOrEmpty(newPassword))
            {
                return(English.PasswordIsEmpty());
            }

            if (GlobalVariables.ActualUser.Password != new Segédfüggvények().EncryptPassword(oldpassword))
            {
                return(English.BadOldPassword());
            }

            if (newPassword.Length < 6 && newPassword.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            GlobalVariables.ActualUser.Password = new Segédfüggvények().EncryptPassword(newPassword);

            return(UpdateUser(GlobalVariables.ActualUser));
        }
Beispiel #5
0
        public string UpdatePassword(string oldpassword, string newPassword)
        {
            if (String.IsNullOrEmpty(oldpassword) || String.IsNullOrEmpty(newPassword))
            {
                return(English.ThisEmailIsExist());
            }

            if (GlobalVariables.ActualUser.Password != oldpassword)
            {
                return(English.BadPasswordLength());
            }

            if (newPassword.Length < 6 && newPassword.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            GlobalVariables.ActualUser.Password = newPassword;

            return(UpdateUser(GlobalVariables.ActualUser));
        }
        public async Task <string> SignUpAsync(User user)
        {
            if (String.IsNullOrEmpty(user.Email) || String.IsNullOrEmpty(user.FirstName) ||
                String.IsNullOrEmpty(user.LastName) || String.IsNullOrEmpty(user.Password))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (user.Password.Length < 6 && user.Password.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            user.Email = user.Email.ToLower();

            var isItAUser = DependencyService.Get <IDBAccess.IBlobStorage>().GetUserByEmail(user.Email);

            if (isItAUser.Email is null)
            {
                var success = DependencyService.Get <IDBAccess.IBlobStorage>().InsertUser(user);

                if (success)
                {
                    string         url     = String.Format("http://petbellies.com/php/petbelliesreg.php?email={0}&nev={1}", user.Email, user.FirstName);
                    Uri            uri     = new Uri(url);
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.Method = "GET";
                    WebResponse res = await request.GetResponseAsync();

                    return(English.Empty());
                }
            }
            else
            {
                return(English.ThisEmailIsExist());
            }

            return(English.SomethingWentWrong());
        }