public void Add(Authorization a) { a.Valid = true; context.AddObject("Authorization", AuthorizationToDbAuthorization(a)); context.SaveChangesWithRetries(); context.Detach(a); }
private AuthorizationDb AuthorizationToDbAuthorization(Authorization a) { AuthorizationDb d = new AuthorizationDb(); d.CustomerID = a.CustomerID; d.EmailAddress = a.EmailAddress; d.PartitionKey = a.Token; d.RowKey = a.UniqueID; d.Valid = a.Valid; d.Type = a.Type; return d; }
private Authorization DbAuthorizationToAuthorization(AuthorizationDb d) { Authorization a = new Authorization(); a.UniqueID = d.RowKey; a.Token = d.PartitionKey; a.EmailAddress = d.EmailAddress; a.CustomerID = d.CustomerID; a.Valid = d.Valid; return a; }
public Authorization AuthorizeCustomer(Login l) { ICustomerRepository repo = Models.RepoFactory.GetCustomerRepo(); Customer c=null; if (!l.EmailAddress.Equals("")) { c = repo.GetWithEmailAddress(l.EmailAddress); if (c == null) return null; if (!l.Password.ToUpper().Equals(c.Password.ToUpper())) return null; } else { Facebook.FacebookClient fb = new Facebook.FacebookClient(); c = repo.GetWithFacebookID(l.FacebookID); if (c == null) return null; fb.AccessToken = l.FacebookToken; try { dynamic me = fb.Get("me"); if (me == null || me.first_name.Equals("")) return null; } catch (Exception e) { return null; } c.FacebookAccessToken = l.FacebookToken; repo.Update(c); // store the newest Facebook access token since it may have changed } Authorization a = new Authorization("test" + System.DateTime.Now.Ticks.ToString()); a.CustomerID = c.ID; a.EmailAddress = c.EmailAddress; a.Type = c.Type; IAuthorizationRepository authRepo = new AuthorizationRepository(); authRepo.Add(a); // store the auth token in the repo return a; }
public AuthorizationDb(Authorization a) { this.PartitionKey = a.Token; this.RowKey = a.UniqueID; }
//[HttpPost] //public void Claim( /* private void CoreHandleFacebookSignup(Customer newCustomer) { Customer tryFB = Repo.GetWithFacebookID(newCustomer.FacebookUserID); // if we have an unclaimed FB user, claim them now // rather than making a new account. if (tryFB != null && tryFB.FacebookUserID == newCustomer.FacebookUserID) { tryFB.Type = (int)Customer.TypeCodes.Default; tryFB.FacebookAccessToken = newCustomer.FacebookAccessToken; tryFB.FacebookExpires = newCustomer.FacebookExpires; Repo.Update(tryFB); } else { Repo.Add(newCustomer); } }*/ private void CoreCreateSendVerificationEmail(Customer newCustomer) { AuthorizationRepository authRepo = new AuthorizationRepository(); Authorization a = new Authorization("verify-" + Guid.NewGuid().ToString()); a.Valid = false; a.EmailAddress = newCustomer.EmailAddress; a.CustomerID = newCustomer.ID; authRepo.Add(a); String authUrl = "http://dareme.to/verify/" + a.Token; }
public void Verify(Authorization verify) { }