liquid_feedback_frontend

diff app/main/index/_action/login.lua @ 1528:d8fd5b7832f9

merge
author bsw
date Thu Aug 27 09:17:57 2020 +0200 (2020-08-27)
parents 45fd259aa1ad
children
line diff
     1.1 --- a/app/main/index/_action/login.lua	Thu Aug 27 09:17:26 2020 +0200
     1.2 +++ b/app/main/index/_action/login.lua	Thu Aug 27 09:17:57 2020 +0200
     1.3 @@ -16,94 +16,10 @@
     1.4    return
     1.5  end
     1.6  
     1.7 -local function do_etherpad_auth(member)
     1.8 -  local result = net.curl(
     1.9 -    config.etherpad.api_base
    1.10 -    .. "api/1/createAuthorIfNotExistsFor?apikey=" .. config.etherpad.api_key
    1.11 -    .. "&name=" .. encode.url_part(member.name) .. "&authorMapper=" .. tostring(member.id)
    1.12 -  )
    1.13 -  
    1.14 -  if not result then
    1.15 -    slot.put_into("error", _"Etherpad authentication failed" .. " 1")
    1.16 -    return false
    1.17 -  end
    1.18 -  
    1.19 -  local etherpad_author_id = string.match(result, '"authorID"%s*:%s*"([^"]+)"')
    1.20 -  
    1.21 -  if not etherpad_author_id then
    1.22 -    slot.put_into("error", _"Etherpad authentication failed" .. " 2")
    1.23 -    return false
    1.24 -  end
    1.25 -  
    1.26 -  local time_in_24h = os.time() + 24 * 60 * 60
    1.27 -  
    1.28 -  local result = net.curl(
    1.29 -    config.etherpad.api_base 
    1.30 -    .. "api/1/createSession?apikey=" .. config.etherpad.api_key
    1.31 -    .. "&groupID=" .. config.etherpad.group_id
    1.32 -    .. "&authorID=" .. etherpad_author_id
    1.33 -    .. "&validUntil=" .. time_in_24h
    1.34 -  )
    1.35 -
    1.36 -  if not result then
    1.37 -    slot.put_into("error", _"Etherpad authentication failed" .. " 3")
    1.38 -    return false
    1.39 -  end
    1.40 -  
    1.41 -  local etherpad_sesion_id = string.match(result, '"sessionID"%s*:%s*"([^"]+)"')
    1.42 -
    1.43 -  if not etherpad_sesion_id then
    1.44 -    slot.put_into("error", _"Etherpad authentication failed" .. " 4")
    1.45 -    return false
    1.46 -  end
    1.47 -
    1.48 -  request.set_cookie{
    1.49 -    path = config.etherpad.cookie_path,
    1.50 -    name = "sessionID",
    1.51 -    value = etherpad_sesion_id
    1.52 -  }
    1.53 -end
    1.54  
    1.55  if member then
    1.56 -  member.last_login = "now"
    1.57 -  
    1.58 -  local delegations = Delegation:delegations_to_check_for_member_id(member.id)
    1.59 -  
    1.60 -  if config.check_delegations_interval_hard 
    1.61 -      and member.needs_delegation_check_hard
    1.62 -      and #delegations > 0 then
    1.63 -        
    1.64 -    app.session.needs_delegation_check = true
    1.65 -    
    1.66 -  else
    1.67 -    
    1.68 -    if #delegations == 0 then
    1.69 -      member.last_delegation_check = "now"
    1.70 -    end
    1.71 -    
    1.72 -    member.last_activity = "now"
    1.73 -    member.active = true
    1.74 -    
    1.75 -  end
    1.76 -  
    1.77 -  if member.lang == nil then
    1.78 -    member.lang = app.session.lang
    1.79 -  else
    1.80 -    app.session.lang = member.lang
    1.81 -  end
    1.82 +  return util.login(member)
    1.83  
    1.84 -  if member.password_hash_needs_update then
    1.85 -    member:set_password(password)
    1.86 -  end
    1.87 -  
    1.88 -  member:save()
    1.89 -  app.session.member = member
    1.90 -  app.session:save()
    1.91 -
    1.92 -  trace.debug('User authenticated')
    1.93 -  if config.etherpad then
    1.94 -    do_etherpad_auth(member)
    1.95 -  end
    1.96  else
    1.97    slot.put_into("error_code", "invalid_credentials")
    1.98    trace.debug('User NOT authenticated')

Impressum / About Us