Example #1
0
 public void SetPassword()
 {
     byte[] SaltKey;
     Salt     = Encryptions.HashPassword(Password, out SaltKey);
     Key      = SaltKey;
     Password = null;//Salt and key combination will retrieve password
 }
        public static bool SendMessage(string EmailSubject, string EmailBody, string ToEmail)
        {
            string response = "";

            try
            {
                string MaildroidHandle = "skillbase";
                string MaildroidSecret = "bts.skillbase.123";
                string Hash            = Encryptions.SHA512(MaildroidHandle + MaildroidSecret + ToEmail); //SHA512
                var    client          = new RestClient("https://mailrunnerapi.asset.bz/api/");
                var    request         = new RestRequest("Email/Queue", Method.POST);
                request.RequestFormat = DataFormat.Json;
                var body = new
                {
                    Handle         = MaildroidHandle,
                    LogoURL        = "",
                    EmailSubject   = EmailSubject,
                    ContentHeading = "",
                    Body           = EmailBody,
                    ToEmail        = ToEmail,
                    ButtonText     = "",
                    ButtonURL      = ""
                };

                request.AddHeader("Hash", Hash);
                request.AddJsonBody(body);

                response = client.Execute(request).Content;
                if (response.Replace('"', ' ').Trim() == "0")
                {
                    return(true);
                }
                else
                {
                    Logger.Error("Email service returned: " + response);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(false);
        }
Example #3
0
        public static Users Authenticate(string Email, string password, bool StayLoggedIn = false)
        {
            try
            {
                var user = Users.Get(Email);
                if (user == null)
                {
                    return(null);
                }

                if (!Encryptions.VerifyPassword(password, user.Salt, user.Key))
                {
                    return(null);
                }
                return(user.Stripped());
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(null);
        }