()
| 11 | Roles = ['normal_user']) |
| 12 | @limiter.limit("3 per day") |
| 13 | def user_password_set_api(): |
| 14 | |
| 15 | spec_list = [{"password" : str}, |
| 16 | {"password_check": str}] |
| 17 | |
| 18 | log, input, untrusted_input = regular_input.master(request=request, |
| 19 | spec_list=spec_list) |
| 20 | if len(log["error"].keys()) >= 1: |
| 21 | return jsonify(log=log), 400 |
| 22 | |
| 23 | if not valid_password(input['password']): |
| 24 | log['error']['password'] = "Password must be between 8 and 200 characters." |
| 25 | return jsonify(log=log), 400 |
| 26 | |
| 27 | if input['password'] != input['password_check']: |
| 28 | log['error']['password'] = "Paswords must match" |
| 29 | return jsonify(log=log), 400 |
| 30 | |
| 31 | |
| 32 | with sessionMaker.session_scope() as session: |
| 33 | |
| 34 | user = User.get(session = session) |
| 35 | |
| 36 | user.password_hash = hashing_functions.make_password_hash( |
| 37 | user.email, |
| 38 | input['password']) |
| 39 | |
| 40 | Event.new( |
| 41 | kind = "user_set_password", |
| 42 | session = session, |
| 43 | member = user.member, |
| 44 | success = True |
| 45 | ) |
| 46 | |
| 47 | log['success'] = True |
| 48 | return jsonify(log=log), 200 |
| 49 | |
| 50 | |
| 51 |
nothing calls this directly
no test coverage detected