Ejemplo n.º 1
0
 public MinStatPrincipal(User user)
 {
     _identity = new MinStatIdentity
       {
       Id = user.Id,
       Mail = user.Mail,
       EnterpriseId = user.EnterpriseId,
       FirstName = user.FirstName,
       LastName = user.LastName,
       Phone = user.Phone
       };
 }
Ejemplo n.º 2
0
 public void SendMessage(User user, NotificationMessage message)
 {
     string fromMail = ConfigurationManager.AppSettings["fromMail"];
     string toMail = user.Mail;
     string subject = message.Subject;
     string content = message.Content;
     MailMessage mailMessage = new MailMessage(fromMail, toMail, subject, content);
     string userName = ConfigurationManager.AppSettings["userName"];
     string password = ConfigurationManager.AppSettings["password"];
     string smtpClientHost = ConfigurationManager.AppSettings["smtpClientHost"];
     SmtpClient client = new SmtpClient(smtpClientHost);
     client.Credentials = new NetworkCredential(userName, password);
     client.Send(mailMessage);
 }
Ejemplo n.º 3
0
 public void SetUser(User user)
 {
     User userToSet = GetUser(user.Login);
     if (userToSet != null)
     {
         userToSet.FirstName = user.FirstName;
         userToSet.LastName = user.LastName;
         userToSet.Phone = user.Phone;
     }
     else
     {
         context.Users.Add(user);
     }
     context.SaveChanges();
 }
Ejemplo n.º 4
0
        public void SetAuthCookie(User user, bool rememberMe = false)
        {
            string serializedObject = null;
            using (StringWriter sw = new StringWriter())
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(User));
                xmlSerializer.Serialize(sw, user);
                serializedObject = sw.ToString();

            }
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
              1,
              user.Mail,
              DateTime.Now,
              DateTime.Now.AddDays(30),
              rememberMe,
              serializedObject);
            string encTicket = FormsAuthentication.Encrypt(ticket);
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
            HttpContext.Current.Response.Cookies.Add(cookie);
        }