Mercurial Hosting > hghosting
view src/admin/add.txt.luan @ 15:a6e72cd199f1
email security
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 01 Oct 2023 19:53:46 -0600 |
parents | dfc36e7ed22c |
children |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local get_user = Shared.get_user or error() local get_raw_config = Shared.get_raw_config or error() local save_raw_config = Shared.save_raw_config or error() return function() local user = get_user() local repo_name = Http.request.parameters.repo or error "missing repo param" repo_name~="_all" and repo_name~="_private" or error() local mode = Http.request.parameters.mode or error "missing mode param" mode=="public" or mode=="private" or error() Io.stdout = Http.response.text_writer() local raw_config = get_raw_config() local repo = raw_config.repos[repo_name] if repo == nil then raw_config.repos[repo_name] = { mode = mode users = {user} admins = {user} } save_raw_config(raw_config) %>added<% else repo.mode==mode or error "mode mismatch" %>exists<% end end