mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
@@ -1,22 +1,20 @@
|
||||
from flask import session, request, abort
|
||||
from flask_restplus import Namespace, Resource
|
||||
from CTFd.models import db, Users, Solves, Awards, Fails, Tracking, Unlocks, Submissions, Notifications
|
||||
from CTFd.models import db, Users, Solves, Awards, Tracking, Unlocks, Submissions, Notifications
|
||||
from CTFd.utils.decorators import (
|
||||
authed_only,
|
||||
admins_only,
|
||||
authed,
|
||||
ratelimit
|
||||
)
|
||||
from CTFd.cache import cache, clear_standings
|
||||
from CTFd.cache import clear_standings
|
||||
from CTFd.utils.config import get_mail_provider
|
||||
from CTFd.utils.email import sendmail
|
||||
from CTFd.utils.email import sendmail, user_created_notification
|
||||
from CTFd.utils.user import get_current_user, is_admin
|
||||
from CTFd.utils.decorators.visibility import check_account_visibility, check_score_visibility
|
||||
from CTFd.utils.decorators.visibility import check_account_visibility
|
||||
|
||||
from CTFd.utils.config.visibility import (
|
||||
accounts_visible,
|
||||
challenges_visible,
|
||||
registration_visible,
|
||||
scores_visible
|
||||
)
|
||||
|
||||
@@ -46,6 +44,7 @@ class UserList(Resource):
|
||||
'data': response.data
|
||||
}
|
||||
|
||||
@users_namespace.doc(params={'notify': 'Whether to send the created user an email with their credentials'})
|
||||
@admins_only
|
||||
def post(self):
|
||||
req = request.get_json()
|
||||
@@ -61,6 +60,17 @@ class UserList(Resource):
|
||||
db.session.add(response.data)
|
||||
db.session.commit()
|
||||
|
||||
if request.args.get('notify'):
|
||||
name = response.data.name
|
||||
email = response.data.email
|
||||
password = req.get('password')
|
||||
|
||||
user_created_notification(
|
||||
addr=email,
|
||||
name=name,
|
||||
password=password
|
||||
)
|
||||
|
||||
clear_standings()
|
||||
|
||||
response = schema.dump(response.data)
|
||||
|
||||
Reference in New Issue
Block a user