Beispiel #1
0
 /// <summary>
 /// Update an existing token
 /// </summary>
 /// <param name="app"></param>
 public void UpdateToken(Models.TokenModel token)
 {
     using (SqlConnection conn = new SqlConnection(this.GetConnectionString()))
     {
         conn.Open();
         string query = this.GetScript(Scripts.Scripts.UpdateToken);
         Dapper.SqlMapper.Execute(conn, query, token);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Generate a token for the application id
        /// </summary>
        /// <param name="appId"></param>
        /// <returns></returns>
        public Models.TokenModel GenerateToken(string appId)
        {
            var app = this.GetApplication(appId);

            if (app == null)
            {
                return(null);
            }

            var token = new Models.TokenModel()
            {
                Application_Id = appId,
                CreatedOn      = DateTime.Now,
                ExpiresOn      = DateTime.Now.AddMinutes(this.Settings.Token_Expiry_Minutes),
                Token          = Guid.NewGuid().ToString()
            };

            this.InsertToken(token);

            return(token);
        }