Пример #1
0
        public TokenString Login([FromBody] LoginInfo user)
        {
            var dbUser = (from m in db.Users
                          where m.Email == user.Email
                          select m).First();
            TokenString token = new TokenString();

            token.Token = "invalid";
            if (PasswordHash.ValidatePassword(user.Password, dbUser.Password) && dbUser.Confirmed == 1)
            {
                token.Token = BitConverter.ToString(AesConfig.EncryptStringToBytes_Aes(user.Email)).Replace("-", string.Empty);
                //token.Token= Convert.ToBase64String(AesConfig.EncryptStringToBytes_Aes(user.Email));
            }
            return(token);
        }
Пример #2
0
        public string Create([FromBody] User value)
        {
            value.Confirmed = 0;
            value.Password  = PasswordHash.CreateHash(value.Password);
            db.Users.Add(value);
            string id   = BitConverter.ToString(AesConfig.EncryptStringToBytes_Aes(value.Email)).Replace("-", string.Empty);
            string link = "https://pkg.apphb.com/#confirm=" + id;

            try
            {
                Mailer.Mailer.SendMail(value.Email, "PKG Registration", "You have been successfully registered to this PKG, in order to start using your key, you need to activate your account first. To do so click this [link](" + link + ")");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            db.SaveChanges();
            return("User successfully created");
        }