mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[user_registration] add first functions
This commit is contained in:
parent
e4f83f3413
commit
b7aefe5167
2 changed files with 68 additions and 0 deletions
|
@ -52,6 +52,9 @@ do_init_regen() {
|
||||||
# Empty service conf
|
# Empty service conf
|
||||||
touch /etc/yunohost/services.yml
|
touch /etc/yunohost/services.yml
|
||||||
|
|
||||||
|
# Make sure the subscriptions file exists
|
||||||
|
touch /etc/yunohost/subscriptions.yml
|
||||||
|
|
||||||
mkdir -p /var/cache/yunohost/repo
|
mkdir -p /var/cache/yunohost/repo
|
||||||
chown root:root /var/cache/yunohost
|
chown root:root /var/cache/yunohost
|
||||||
chmod 700 /var/cache/yunohost
|
chmod 700 /var/cache/yunohost
|
||||||
|
|
65
src/user.py
65
src/user.py
|
@ -25,10 +25,15 @@ import random
|
||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
import copy
|
import copy
|
||||||
|
import yaml
|
||||||
|
|
||||||
from moulinette import Moulinette, m18n
|
from moulinette import Moulinette, m18n
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
from moulinette.utils.process import check_output
|
from moulinette.utils.process import check_output
|
||||||
|
from moulinette.utils.filesystem import (
|
||||||
|
read_yaml,
|
||||||
|
write_to_yaml,
|
||||||
|
)
|
||||||
|
|
||||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||||
from yunohost.service import service_status
|
from yunohost.service import service_status
|
||||||
|
@ -1442,6 +1447,66 @@ def user_ssh_remove_key(username, key):
|
||||||
# End SSH subcategory
|
# End SSH subcategory
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Subcription subcategory
|
||||||
|
#
|
||||||
|
|
||||||
|
REGISTRATIONS = "/etc/yunohost/registrations.yml"
|
||||||
|
|
||||||
|
def user_subscription_list():
|
||||||
|
"""
|
||||||
|
List pending subscriptions
|
||||||
|
"""
|
||||||
|
|
||||||
|
return read_yaml(REGISTRATIONS).get("subscriptions", None)
|
||||||
|
|
||||||
|
#TODO: user_subscription_accept(username)
|
||||||
|
|
||||||
|
def user_subscription_deny(username):
|
||||||
|
"""
|
||||||
|
Deny a pending subscription
|
||||||
|
"""
|
||||||
|
|
||||||
|
registrations = read_yaml(REGISTRATIONS)
|
||||||
|
for r in registrations["subscriptions"]:
|
||||||
|
if r["username"] == username:
|
||||||
|
registrations.remove(r)
|
||||||
|
write_to_yaml(registrations)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def user_subscription_invite_list():
|
||||||
|
"""
|
||||||
|
List current invitations
|
||||||
|
"""
|
||||||
|
|
||||||
|
return read_yaml(REGISTRATIONS).get("invitations", None)
|
||||||
|
|
||||||
|
#TODO: user_subscription_invite_create(email, groups, quota, nb_account)
|
||||||
|
|
||||||
|
def user_subscription_invite_delete(code):
|
||||||
|
"""
|
||||||
|
Delete an invitation
|
||||||
|
"""
|
||||||
|
|
||||||
|
registrations = read_yaml(REGISTRATIONS)
|
||||||
|
for r in registrations["invitations"]:
|
||||||
|
if r["code"] == code:
|
||||||
|
registrations.remove(r)
|
||||||
|
write_to_yaml(registrations)
|
||||||
|
return True
|
||||||
|
|
||||||
|
#TODO: user_subscription_captcha(code)
|
||||||
|
|
||||||
|
#TODO: user_subscription_register(username, code, firstname, lastname, password)
|
||||||
|
|
||||||
|
#TODO: user_subscription_resend(code)
|
||||||
|
|
||||||
|
#TODO: user_subscription_validate(username)
|
||||||
|
|
||||||
|
#
|
||||||
|
# End subcription subcategory
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
def _hash_user_password(password):
|
def _hash_user_password(password):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue