Example #1
0
 private void RecordTheLogin(Guid userId)
 {
     //Record the Login
     var ut = new UserLoginTracking()
     {
         UserId = userId,
         LoginMethod = "Epilogger Account",
         DateTime = DateTime.UtcNow,
         IPAddress = HttpContext.Request.UserHostAddress
     };
     new UserLoginTrackingService().Save(ut);
 }
Example #2
0
        private Guid CheckConnectedAccountUserExists(string userScreenName, AuthenticationServices authService, string token, string tokenSecret)
        {
            try
            {

                var userAuthService = new UserAuthenticationProfileService();
                var userAuth = userAuthService.UserAuthorizationByServiceScreenNameAndPlatform(userScreenName, "Web", authService);
                if (userAuth != null)
                {
                    string logInMethod = null;
                    switch (authService)
                    {
                        case AuthenticationServices.TWITTER:
                            userAuth.Token = token;
                            userAuth.TokenSecret = tokenSecret;
                            logInMethod = "Twitter";
                            break;
                        case AuthenticationServices.FACEBOOK:
                            userAuth.Token = token;
                            logInMethod = "Facebook";
                            break;
                    }
                    userAuthService.Save(userAuth);

                    var user = userAuth.Users.FirstOrDefault();
                    if (user != null)
                    {

                        //Record the Login
                        var ut = new UserLoginTracking()
                        {
                            UserId = user.ID,
                            LoginMethod = logInMethod,
                            DateTime = DateTime.UtcNow,
                            IPAddress = HttpContext.Request.UserHostAddress
                        };
                        new UserLoginTrackingService().Save(ut);
                        return user.ID;
                    }
                }

                return Guid.Empty;
            }
            catch (Exception)
            {
                return Guid.Empty;
            }
        }