MCPcopy Index your code
hub / github.com/tiny-pilot/tinypilot / register

Function register

app/auth.py:84–107  ·  view source on GitHub ↗

Creates a new account with the given name and password. Args: username: (str) password: (str) role: (Role) Raises: db.users.UserAlreadyExistsError: If a user with the given username already exists on the system. OneAdminRequiredError

(username, password, role)

Source from the content-addressed store, hash-verified

82
83
84def register(username, password, role):
85 """Creates a new account with the given name and password.
86
87 Args:
88 username: (str)
89 password: (str)
90 role: (Role)
91
92 Raises:
93 db.users.UserAlreadyExistsError: If a user with the given username
94 already exists on the system.
95 OneAdminRequiredError
96 """
97 if len(get_all_accounts()) == 0 and role != Role.ADMIN:
98 raise OneAdminRequiredError(
99 'The very first user account on the system must have admin role.')
100
101 logger.info_sensitive('Adding user %s with role %s', username, role)
102 db.users.Users().add(username=username,
103 password_hash=password_check.generate_hash(password),
104 credentials_change_time=utc.now(),
105 role=role)
106 logger.info_sensitive('Created user %s with role %s', username, role)
107 video_service.restart()
108
109
110def change_password(username, new_password):

Callers

nothing calls this directly

Calls 4

get_all_accountsFunction · 0.85
info_sensitiveMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected