PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/AnotherStartup/App_Code/Account/Confirm.cs

#
C# | 43 lines | 34 code | 6 blank | 3 comment | 2 complexity | 501abf6e37130b3b209e7dabe4c29288 MD5 | raw file
 1using System.Web.WebPages;
 2using WebMatrix.WebData;
 3
 4namespace Account
 5{
 6    /// <summary>
 7    /// Summary description for Confirm
 8    /// </summary>
 9    public static class Confirm
10    {        
11        public class Error
12        {
13            public ErrorMessage ConfirmAccount { get; set; }
14            public Error()
15            {
16                ConfirmAccount = ErrorMessage.Nil;
17            }
18
19        }
20
21        public static void Init(WebPageBase web)
22        {
23            Error error = web.Page.Errors = new Error();
24
25            web.Page.Confirmed = false;
26
27            var confirmationToken = web.Request["confirmationCode"];
28
29            WebSecurity.Logout();
30            if (!confirmationToken.IsEmpty())
31            {
32                if (WebSecurity.ConfirmAccount(confirmationToken))
33                {
34                    web.Page.Confirmed = true;                    
35                }
36                else
37                {
38                    error.ConfirmAccount = web.Error("Could not confirm your registration info");
39                }
40            }
41        }
42    }
43}