コード例 #1
0
        public static void SendVerificationCode(string EmailAddressUser, string NickUser, int UserId)
        {
            int verificationCode = random.Next(1000000, 9999999);

            client.Port        = port;
            client.EnableSsl   = SSL;
            client.Credentials = login;
            msg = new MailMessage()
            {
                From = new MailAddress("*****@*****.**", "E-Gallery", Encoding.UTF8)
            };
            msg.To.Add(new MailAddress(EmailAddressUser));
            msg.Subject      = "Verification Code Registration.";
            msg.Body         = "Hi, " + NickUser + ", this your verification code to registration: " + "<b>" + verificationCode + "</b>";
            msg.BodyEncoding = Encoding.UTF8;
            msg.IsBodyHtml   = true;
            msg.Priority     = MailPriority.Normal;
            msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            client.Send(msg);
            EGalleryEntities db = new EGalleryEntities();

            db.Verification.Add(new Verification()
            {
                UserId           = UserId,
                VerificationCode = Convert.ToString(verificationCode)
            });
            db.SaveChanges();
        }
コード例 #2
0
        public override string[] GetRolesForUser(string username)
        {
            EGalleryEntities db   = new EGalleryEntities();
            string           role = db.Users.FirstOrDefault(x => x.UserURL == username).Role;

            string[] result = { role };
            return(result);
        }