MCPcopy
hub / github.com/diffgram/diffgram / user_password_set_api

Function user_password_set_api

default/methods/user/account/account_password.py:13–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 Roles = ['normal_user'])
12@limiter.limit("3 per day")
13def 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

Callers

nothing calls this directly

Calls 3

valid_passwordFunction · 0.70
getMethod · 0.45
newMethod · 0.45

Tested by

no test coverage detected