This project is read-only.

_authenticationService.SignIn(user.. not logging in?

Topics: General, Troubleshooting
Mar 22, 2012 at 5:07 AM

Hi all, I have the following code:

                var user = _membershipService.GetUser(username);

                if (user == null) {
                    Logger.Warning("User " + username + " doesnt exist?");
                    user.As<UserPart>().RegistrationStatus = UserStatus.Approved;
                    Logger.Warning("User " + username + " has been approved.");

                    _authenticationService.SignIn(user, false);

Am I missing anything that would prevent the user from being logged in?  The Users registrationstatus changes to approved, but they are not logged in? No errors etc.; is there anything I maybe missing in settings? Thanks for your thoughts in anticipation, cheers dyrgutt

Mar 23, 2012 at 1:27 AM

Invoking _authenticationService.SignIn should just work. Are you sure there are no errors? Did you check the Logs? Perhaps also clear your browser cookies?

Mar 23, 2012 at 6:02 AM

Yeah, due to my exceptional coding skills *cough*, I get to hang out at the logs more than I care to imagine, so I was as surprised as you when nothing popped up; as in, I was writing to the logger as well to check my progress and all messages prior/during/after the call came through.

To fill you in a bit more, I’m receiving a ‘developer test’ PayPal IPN, and upon receipt of confirmed donation, I approve the registrationstatus, then *hopefully* log the user in – that’s where it goes amiss.  I’m thinking doing it through the IPN may be the issue – perhaps I can only do it thought the PDT?  Any thoughts very much appreciated as per usual, cheers Dyr

Mar 23, 2012 at 10:36 AM

Oh! If I understand corectly, you are trying to log the user in in response to an HTTP request from the server of PayPal? If it's a server to server request indeed, then there's no way to sign in the user at that point. The reason being of course that the Signin method will create a cookie, which will be sent to the server of PayPal, not to the browser session of your user.

Instead, you need to sign in the user when handling a request that comes from his browser.
If that is already the case, then I'm clueless still.

Mar 23, 2012 at 8:13 PM

Yeah, I believe you're right mate - I ended up transposing the code to the PDT [a simple view on my site that handles the redirect/receipt of PayPal confirmation details], not as fool-proof as the IPN [as a user may abort the redirect process/prematurely exit; but so be it, they'll just have to login manually]. Anyhow, it works - so i'm very happy. A thousand thanks for all your efforts mate, and respect to all the help you offer everyone here on the forum, very grateful - cheers Dyr