Example #1
0
 UserModel BuildUser(string provider, string field)
 {
     Dictionary<string, string> token = new Dictionary<string, string>();
     UserModel CurrentUser = new UserModel();
     if (HttpContext.Current.Request.Headers["Authorization"] != null)
     {
         string id_token = HttpContext.Current.Request.Headers.GetValues("Authorization").FirstOrDefault().Substring(7);
         token = TokenUtility.GenToken(id_token);
         DateTime expTime = new DateTime(1970, 1, 1)
             .AddSeconds(Convert.ToDouble(token["exp"]));
         Employee emp = TimeUnit.Employees.Get(x => x.Email == token[field]).FirstOrDefault();
         CurrentUser = TimeFactory.Create(emp, provider);
     }
     return CurrentUser;
 }