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

登录接口session模块在get和post的时候一直报错 #1

Open
ppinggpp opened this issue Feb 25, 2021 · 0 comments
Open

登录接口session模块在get和post的时候一直报错 #1

ppinggpp opened this issue Feb 25, 2021 · 0 comments

Comments

@ppinggpp
Copy link

ppinggpp commented Feb 25, 2021

local function check_login()
    return function(req, res, next)
        local requestPath = req.path
        local in_white_list = false
        if requestPath == "/auth/login" then
	    	in_white_list = true
	    end
        local islogin, user= is_login(req) --这一段还没登录就去获取session,导致session.lua一直报错
        if in_white_list then
            next()
        else
            if islogin then
                res.locals.login = islogin
                res.locals.username = user and user.username
                next()
            else
                res:redirect("/auth/login")
            end
        end
    end
end

2021/02/26 00:14:43 [error] 1889#0: *1884 [lua] session.lua:85: func(): cannot get session_data:no cookie found in the current request, client: 192.168.0.130, server: 192.168.0.111, request: "POST /auth/login HTTP/1.1", host: "192.168.0.111", referrer: "http://192.168.0.111/auth/login"
2021/02/26 00:14:49 [error] 1889#0: *1884 [lua] session.lua:85: func(): cannot get session_data:no cookie found in the current request, client: 192.168.0.130, server: 192.168.0.111, request: "GET /auth/login HTTP/1.1", host: "192.168.0.111"
2021/02/26 00:14:58 [error] 1889#0: *1888 [lua] session.lua:85: func(): cannot get session_data:no cookie found in the current request, client: 192.168.0.130, server: 192.168.0.111, request: "POST /auth/login HTTP/1.1", host: "192.168.0.111", referrer: "http://192.168.0.111/auth/login"

第一次提issues希望没提错,

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