cabinet-manage/git/admin.py

37 lines
956 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding:utf-8 -*-
'''
@AuthorRobin
@Email: 329080237@qq.com
@Wechat: 15618110227
@File: admin.py
@Date: 2021/9/25 14:59
@Description:
'''
from web.git.base import RequestGit
from web.git.users import updateToken
def createUser(request, email, username, password):
api = "/admin/users"
formData = {
"email": email,
"full_name": username,
"login_name": username,
"must_change_password": False,
"password": password,
"send_notify": True,
"source_id": 0,
"username": username
}
res = RequestGit(request, api).post(formData, token=True)
if res.status_code == 201: #创建帐号成功
pass
# 更新 用户Token
#updateToken(request, username, password)
else:
# 创建失败token已存在其它原因失败)
raise Exception("Gitea授权失败请重新登录")
#print(res.status_code)
return res.text