liquid_feedback_frontend

annotate app/main/member/_action/update_api_key.lua @ 75:733f65c0c0a0

Bugfixes, feature enhancements, code-cleanup, and major work on API

Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
author bsw
date Thu Jul 08 18:44:02 2010 +0200 (2010-07-08)
parents 0849be391140
children 976d493106a1
rev   line source
bsw@51 1
bsw@51 2 local setting_key = "liquidfeedback_frontend_api_key"
bsw@51 3 local setting = Setting:by_pk(app.session.member.id, setting_key)
bsw@51 4
bsw@51 5 local api_key
bsw@51 6
bsw@51 7 if param.get("delete", atom.boolean) then
bsw@51 8
bsw@51 9 if setting then
bsw@51 10 setting:destroy()
bsw@51 11 end
bsw@51 12
bsw@51 13 else
bsw@51 14
bsw@51 15 if not setting then
bsw@51 16 setting = Setting:new()
bsw@51 17 setting.member_id = app.session.member.id
bsw@51 18 setting.key = setting_key
bsw@51 19 end
bsw@51 20
bsw@51 21 api_key = multirand.string(
bsw@51 22 20,
bsw@51 23 '23456789BCDFGHJKLMNPQRSTVWXYZbcdfghjkmnpqrstvwxyz'
bsw@51 24 )
bsw@51 25
bsw@51 26 setting.value = api_key
bsw@51 27
bsw@51 28 setting:save()
bsw@51 29 end
bsw@51 30
bsw@51 31
bsw@51 32 local setting_key = "liquidfeedback_frontend_api_key_history"
bsw@51 33
bsw@51 34 setting = SettingMap:new()
bsw@51 35 setting.member_id = app.session.member.id
bsw@51 36 setting.key = setting_key
bsw@51 37 setting.subkey = db:query("SELECT now()")[1].now
bsw@51 38 setting.value = api_key or ""
bsw@51 39 local dberr = setting:try_save()
bsw@51 40
bsw@51 41 if dberr then
bsw@51 42 if dberr:is_kind_of("IntegrityConstraintViolation.UniqueViolation") then
bsw@51 43 slot.put_into("error", _"The API key has been changed too fast.")
bsw@51 44 return
bsw@51 45 else
bsw@51 46 dberr:escalate()
bsw@51 47 end
bsw@51 48 end
bsw@51 49
bsw@51 50 if not api_key then
bsw@51 51 slot.put_into("notice", _"API key has been deleted")
bsw@51 52 else
bsw@51 53 slot.put_into("notice", _"API key has been updated")
bsw@51 54 end

Impressum / About Us