Skip to content
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

File session store doesn't work #33

Open
raygray opened this issue Aug 4, 2014 · 0 comments
Open

File session store doesn't work #33

raygray opened this issue Aug 4, 2014 · 0 comments

Comments

@raygray
Copy link

raygray commented Aug 4, 2014

First of all, congratulations for your excellent work on Beego and Wetalk!

I was playing a bit with Wetalk and found out that session store doesn't work when FileSessionStore is used as provider (everything works fine with MemSessionStore). The problem seems similar to this Beego ticket - if a user logs in and opens a protected page (User Home or User Profile) and then refreshes (reloads) that page in a browser, (s)he automatically lands on the login page again.
After inspecting the code, I found this chunk of code suspicious (modules/auth/auth.go):

func LoginUser(user *models.User, ctx *context.Context, remember bool) {
    // weird way of beego session regenerate id...
    ctx.Input.CruSession.SessionRelease(ctx.ResponseWriter)
    ctx.Input.CruSession = beego.GlobalSessions.SessionRegenerateId(ctx.ResponseWriter, ctx.Request)
    ctx.Input.CruSession.Set("auth_user_id", user.Id)

The problem is that the method Set is called after the SessionRelease (which saves the session) and therefore "auth_user_id" is not saved at all. You can put ctx.Input.CruSession.Setin front of ctx.Input.CruSession.SessionRelease but it doesn't solve the problem - SessionRegenerate doesn't decode "auth_user_id" value properly. I didn't investigate this further - maybe there is something wrong with init function in astaxie/beego/session/sess_utils.go...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant