Show More
@@ -63,6 +63,7 b' def get_user(request, apiuser, userid=Op' | |||||
63 | "active": true, |
|
63 | "active": true, | |
64 | "admin": false, |
|
64 | "admin": false, | |
65 | "api_keys": [ list of keys ], |
|
65 | "api_keys": [ list of keys ], | |
|
66 | "auth_tokens": [ list of tokens with details ], | |||
66 | "email": "user@example.com", |
|
67 | "email": "user@example.com", | |
67 | "emails": [ |
|
68 | "emails": [ | |
68 | "user@example.com" |
|
69 | "user@example.com" |
@@ -915,6 +915,7 b' class User(Base, BaseModel):' | |||||
915 |
|
915 | |||
916 | extras = { |
|
916 | extras = { | |
917 | 'api_keys': [api_key_replacement], |
|
917 | 'api_keys': [api_key_replacement], | |
|
918 | 'auth_tokens': [api_key_replacement], | |||
918 | 'active': user.active, |
|
919 | 'active': user.active, | |
919 | 'admin': user.admin, |
|
920 | 'admin': user.admin, | |
920 | 'extern_type': user.extern_type, |
|
921 | 'extern_type': user.extern_type, | |
@@ -927,6 +928,7 b' class User(Base, BaseModel):' | |||||
927 |
|
928 | |||
928 | if include_secrets: |
|
929 | if include_secrets: | |
929 | data['api_keys'] = user.auth_tokens |
|
930 | data['api_keys'] = user.auth_tokens | |
|
931 | data['auth_tokens'] = user.extra_auth_tokens | |||
930 | return data |
|
932 | return data | |
931 |
|
933 | |||
932 | def __json__(self): |
|
934 | def __json__(self): | |
@@ -985,6 +987,21 b' class UserApiKeys(Base, BaseModel):' | |||||
985 | def __unicode__(self): |
|
987 | def __unicode__(self): | |
986 | return u"<%s('%s')>" % (self.__class__.__name__, self.role) |
|
988 | return u"<%s('%s')>" % (self.__class__.__name__, self.role) | |
987 |
|
989 | |||
|
990 | def __json__(self): | |||
|
991 | data = { | |||
|
992 | 'auth_token': self.api_key, | |||
|
993 | 'role': self.role, | |||
|
994 | 'scope': self.scope_humanized, | |||
|
995 | 'expired': self.expired | |||
|
996 | } | |||
|
997 | return data | |||
|
998 | ||||
|
999 | @property | |||
|
1000 | def expired(self): | |||
|
1001 | if self.expires == -1: | |||
|
1002 | return False | |||
|
1003 | return time.time() > self.expires | |||
|
1004 | ||||
988 | @classmethod |
|
1005 | @classmethod | |
989 | def _get_role_name(cls, role): |
|
1006 | def _get_role_name(cls, role): | |
990 | return { |
|
1007 | return { | |
@@ -996,12 +1013,6 b' class UserApiKeys(Base, BaseModel):' | |||||
996 | }.get(role, role) |
|
1013 | }.get(role, role) | |
997 |
|
1014 | |||
998 | @property |
|
1015 | @property | |
999 | def expired(self): |
|
|||
1000 | if self.expires == -1: |
|
|||
1001 | return False |
|
|||
1002 | return time.time() > self.expires |
|
|||
1003 |
|
||||
1004 | @property |
|
|||
1005 | def role_humanized(self): |
|
1016 | def role_humanized(self): | |
1006 | return self._get_role_name(self.role) |
|
1017 | return self._get_role_name(self.role) | |
1007 |
|
1018 |
General Comments 0
You need to be logged in to leave comments.
Login now