|
@@ -37,6 +37,12 @@ class User(Model):
|
|
except peewee.IntegrityError:
|
|
except peewee.IntegrityError:
|
|
raise e.UserExists(name=user.name)
|
|
raise e.UserExists(name=user.name)
|
|
|
|
|
|
|
|
+ def change_password(self, req: r.PasswordChange):
|
|
|
|
+ if not pwd.verify(req.old, self.passhash):
|
|
|
|
+ raise e.BadPassword(name=self.name)
|
|
|
|
+ self.passhash = pwd.hash(req.n1)
|
|
|
|
+ self.save()
|
|
|
|
+
|
|
@staticmethod
|
|
@staticmethod
|
|
def from_invite(user: r.User, token: str) -> "User":
|
|
def from_invite(user: r.User, token: str) -> "User":
|
|
invite = UserInvite.by_code(token)
|
|
invite = UserInvite.by_code(token)
|
|
@@ -72,6 +78,9 @@ class User(Model):
|
|
def base_url(self) -> str:
|
|
def base_url(self) -> str:
|
|
return f"/u/{self.name}"
|
|
return f"/u/{self.name}"
|
|
|
|
|
|
|
|
+ def config_url(self) -> str:
|
|
|
|
+ return f"/u/{self.name}/config"
|
|
|
|
+
|
|
def get_links(
|
|
def get_links(
|
|
self, as_user: Optional["User"], page: int
|
|
self, as_user: Optional["User"], page: int
|
|
) -> Tuple[List[v.Link], v.Pagination]:
|
|
) -> Tuple[List[v.Link], v.Pagination]:
|
|
@@ -97,7 +106,7 @@ class User(Model):
|
|
def to_dict(self) -> dict:
|
|
def to_dict(self) -> dict:
|
|
return {"id": self.id, "name": self.name}
|
|
return {"id": self.id, "name": self.name}
|
|
|
|
|
|
- def get_config(self) -> v.Config:
|
|
|
|
|
|
+ def get_config(self, status_msg: Optional[int]) -> v.Config:
|
|
admin_pane = None
|
|
admin_pane = None
|
|
if self.is_admin:
|
|
if self.is_admin:
|
|
user_invites = [
|
|
user_invites = [
|
|
@@ -109,7 +118,7 @@ class User(Model):
|
|
for ui in UserInvite.select().where(UserInvite.created_by == self)
|
|
for ui in UserInvite.select().where(UserInvite.created_by == self)
|
|
]
|
|
]
|
|
admin_pane = v.AdminPane(invites=user_invites)
|
|
admin_pane = v.AdminPane(invites=user_invites)
|
|
- return v.Config(username=self.name, admin_pane=admin_pane,)
|
|
|
|
|
|
+ return v.Config(username=self.name, admin_pane=admin_pane, msg=status_msg)
|
|
|
|
|
|
def import_pinboard_data(self, stream):
|
|
def import_pinboard_data(self, stream):
|
|
try:
|
|
try:
|