Ejemplo n.º 1
0
        public static User Create()
        {
            var conn = DatabaseConnection
            .GetOpenConnection();
            var cmd = conn.CreateCommand();
            cmd.CommandText = "INSERT INTO [User] (CookieId) VALUES (NULL);select scope_identity()";
            cmd.CommandType = System.Data.CommandType.Text;

            var id = cmd.ExecuteScalar();
            conn.Close();

            var user = new User();
            user.Id = int.Parse(id.ToString());
            return user;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new authentication cookie for the specified user.
 /// </summary>
 /// <param name="user">The user for which the cookie will be created.</param>
 /// <returns></returns>
 public static HttpCookie Create(User user)
 {
     var authString = user.Id.ToString() + ":" + DateTime.UtcNow.Ticks;
     return new HttpCookie("SocialChoose-Auth", Hash.HmacSha1(Settings.AuthenticationSecretKey, authString) + ":" + authString);
 }