-
Couldn't load subscription status.
- Fork 11
Resync to upstream/master (fix segfault in webapp.d + return bool from login()) #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the inconvenience in situations where oauth is not being used to keep track of user logins. Seems sensible to reconsider the naming, and possibly usage, of isLoggedIn. This commit does not seem to solve the problem correctly.
| +/ | ||
| final | ||
| OAuthSession oauthSession(scope HTTPServerRequest req) nothrow @trusted | ||
| OAuthSession oauthSession(scope HTTPServerRequest req, immutable OAuthSettings settings = null) nothrow @trusted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for oauthSession to not take a settings parameter, is that it should be possible for multi-provider apps to get the OAuthSession regardless of the settings used to login.
As mentioned in the documentation comment, oauthSession is just a getter to be used only after checking for session availability and validity.
| if (auto pCM = "oauth.session" in req.context) | ||
| return pCM.get!OAuthSession; | ||
| else | ||
| return loadSessionToContext(req, settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with this, there's still the possibility of oauthSession returning null, i.e. when the user did not login with OAuth. So the need for a null-check will always exist, unless a session is known to be available (e.g. isLoggedIn is known to have returned true for this request).
| } (); | ||
|
|
||
| loadSessionToContext(req, settings); | ||
| return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would introduce a serious bug. Should only return true if a session is available.
|
Added commit 88e11ac to master. |
So the main problem turned out to be that I use a different method to check for the login state, which means that the session is never added to
req.context. The failure manifested as nasty segfault due to Session being null. Thus, the second commit will add the session toreq.contextas fallback if settings are supplied tooauthSession. In theory,loginshould also have a check for this - maybe inuserAuthUri?The first commit allows to use the result of the
loginfunction, s.t. instead ofWe can write: