()
| 78 | @routes.route('/api/v1/user/new', |
| 79 | methods = ['POST']) |
| 80 | def user_new_api(): |
| 81 | spec_list = [ |
| 82 | {"email": { |
| 83 | 'kind': str, |
| 84 | 'required': True |
| 85 | } |
| 86 | }, |
| 87 | {"signup_code": { |
| 88 | 'kind': str, |
| 89 | 'required': False |
| 90 | } |
| 91 | }, |
| 92 | {"password": { |
| 93 | 'kind': str, |
| 94 | 'required': True |
| 95 | } |
| 96 | }, |
| 97 | {"password_check": { |
| 98 | 'kind': str, |
| 99 | 'required': True |
| 100 | } |
| 101 | } |
| 102 | ] |
| 103 | |
| 104 | log, input, untrusted_input = regular_input.master( |
| 105 | request = request, |
| 106 | spec_list = spec_list) |
| 107 | |
| 108 | if settings.DISABLE_SELF_REGISTRATION: |
| 109 | try: |
| 110 | domain_name = input['email'].split('@')[1] |
| 111 | except: |
| 112 | domain_name = None |
| 113 | if domain_name != 'diffgram.com': |
| 114 | log['error']['DISABLE_SELF_REGISTRATION'] = 'Self registration is disabled. Change install settings to enable.' |
| 115 | return jsonify(log = log), 400 |
| 116 | |
| 117 | if len(log["error"].keys()) >= 1: |
| 118 | return jsonify(log = log), 400 |
| 119 | |
| 120 | if not valid_password(input['password']): |
| 121 | log['error']['password'] = "Password must be between 8 and 200 characters." |
| 122 | return jsonify(log = log), 400 |
| 123 | |
| 124 | if input['password'] != input['password_check']: |
| 125 | log['error']['password'] = "Passwords must match" |
| 126 | return jsonify(log = log), 400 |
| 127 | |
| 128 | with sessionMaker.session_scope() as session: |
| 129 | |
| 130 | email = input['email'].lower() |
| 131 | |
| 132 | new_user, log = user_new_core(session = session, email = email, log = log) |
| 133 | if regular_log.log_has_error(log = log): |
| 134 | return jsonify(log = log), 400 |
| 135 | |
| 136 | user_signup_code = input['signup_code'] |
| 137 |
nothing calls this directly
no test coverage detected