public ActionResult RegisterFacebookMember(string appKey, string facebookKey, string firstName, string lastName, string email, string deviceId, string mobilePhoneNumber = null, string phoneModel = "iPhone") { var apiAccessRepo = new ApiAccessRepository(); var apiAccess = apiAccessRepo.GetMemberByPublicApiKey(appKey); var apiAuthResult = new ApiAuthResult(); if (null != apiAccess) { try { var memberRepo = new MemberRepository(); var now = DateTime.Now; var member = memberRepo.GetByFacebookKey(facebookKey); if (null == member) { member = new Member(); member.FirstName = firstName; member.LastName = lastName; member.Email = email; member.FacebookId = facebookKey; member.DateCreated = now; member.MemberTypeId = 1; } member.DateUpdated = now; member.DateLastAccessed = now; memberRepo.Save(member); //Now Get User Auth Token var authService = new AuthenticationService(); var auth = authService.GetAuthenticatedMemberLoginToken(apiAccess, member); apiAuthResult.Success = auth.Success; apiAuthResult.Description = auth.Reason; apiAuthResult.AuthKey = auth.AuthKey; }catch(Exception e) { apiAuthResult.Success = false; apiAuthResult.Description = "Failed to save member and/or generate auth token"; apiAuthResult.AuthKey = ""; } }else { apiAuthResult.Success = false; apiAuthResult.Description = "Invalid AppKey"; apiAuthResult.AuthKey = ""; } return this.ToXml(apiAuthResult); }
/// <summary> /// CTOR /// </summary> /// public AuthenticateAttribute() { this.repo = new ApiAccessRepository(); }