Merge pull request #114 from YunoHost/fix_password_issue

[fix] SSOwat crash after password change
This commit is contained in:
Alexandre Aubin 2019-01-17 23:22:00 +01:00 committed by GitHub
commit b5ce673840
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -355,6 +355,15 @@ function set_headers(user)
conf["ldap_identifier"].."=".. user ..","..conf["ldap_group"], conf["ldap_identifier"].."=".. user ..","..conf["ldap_group"],
cache:get(user.."-password") cache:get(user.."-password")
) )
-- If the ldap connection fail (because the password was changed).
-- Logout the user and invalid the password
if not ldap then
ngx.log(ngx.NOTICE, "LDAP connection failed. Disconnect user : ".. user)
cache:delete(authUser.."-password")
flash("info", t("please_login"))
local back_url = ngx.var.scheme .. "://" .. ngx.var.host .. ngx.var.uri .. uri_args_string()
return redirect(conf.portal_url.."?r="..ngx.encode_base64(back_url))
end
ngx.log(ngx.NOTICE, "Reloading LDAP values for: "..user) ngx.log(ngx.NOTICE, "Reloading LDAP values for: "..user)
for dn, attribs in ldap:search { for dn, attribs in ldap:search {
base = conf["ldap_identifier"].."=".. user ..","..conf["ldap_group"], base = conf["ldap_identifier"].."=".. user ..","..conf["ldap_group"],
@ -938,6 +947,7 @@ function logout()
delete_cookie() delete_cookie()
cache:delete("session_"..authUser) cache:delete("session_"..authUser)
cache:delete(authUser.."-"..conf["ldap_identifier"]) -- Ugly trick to reload cache cache:delete(authUser.."-"..conf["ldap_identifier"]) -- Ugly trick to reload cache
cache:delete(authUser.."-password")
flash("info", t("logged_out")) flash("info", t("logged_out"))
end end