예제 #1
0
        public string Activate(string token)
        {
            string               sresult = Cryptor.Decrypt(token, Util.GetDefaultPassword());
            ActivateStruct       S       = JsonConvert.DeserializeObject(sresult, typeof(ActivateStruct)) as ActivateStruct;
            IParameterCollection Params  = new ParameterCollection();

            Params.Add("@id", S.userid);
            Params.Add("@login", S.username);
            Params.Add("@password", Util.GetPassword(S.username));
            SqlManager M = new DersaAnonimousSqlManager();

            int checkresult = M.ExecuteSPWithResult("DERSA_USER$Activate", false, Params);

            return(S.username);
        }
예제 #2
0
        public string Token(string login, string email = "")
        {
            ActivateStruct S      = new ActivateStruct(login, 1);
            string         JS     = JsonConvert.SerializeObject(S);
            string         result = Cryptor.Encrypt(JS, Util.GetDefaultPassword());
            string         token  = System.Web.HttpUtility.UrlEncode(result);
            SmtpClient     Smtp   = new SmtpClient("robots.1gb.ru", 25);

            Smtp.Credentials = new NetworkCredential("u483752", "5b218ad92ui");
            MailMessage Message = new MailMessage();

            Message.From = new MailAddress("*****@*****.**");
            DersaAnonimousSqlManager DM = new DersaAnonimousSqlManager();

            System.Data.DataTable T = DM.ExecuteSPWithParams("DERSA_USER$GetInfo", new object[] { login });
            if (email == "")
            {
                if (T.Rows.Count > 0)
                {
                    email = Cryptor.Decrypt(T.Rows[0]["email"].ToString(), Util.GetDefaultPassword());
                }
            }
            if (email == "")
            {
                return("Undefined email");
            }
            Message.To.Add(new MailAddress(email));
            Message.Subject = "регистрация в проекте DERSA";
            Message.Body    = string.Format("Вы успешно зарегистрировались в проекте DERSA. Для активации вашего аккаунта пройдите по ссылке: http://{0}/account/activate?token={1}", HttpContext.Current.Request.Url.Authority, token);

            try
            {
                Smtp.Send(Message);
                return("Success! Letter sent to " + email + "(robots.1gb.ru, 25) ; token = [" + token + "]");
            }
            catch (SmtpException exc)
            {
                return(exc.Message);
            }
            return("Unknown error");
        }