Register applications with Branded name for UI Dropdown

This commit is contained in:
Jens Langhammer 2019-02-23 20:42:14 +01:00
parent 66c0fc9d9a
commit e5a405bf43
6 changed files with 15 additions and 9 deletions

View file

@ -13,7 +13,7 @@ from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect
LOGGER = getLogger(__name__)
@MANAGER.source(kind=RequestKind.redirect, name='discord')
@MANAGER.source(kind=RequestKind.redirect, name='Discord')
class DiscordOAuthRedirect(OAuthRedirect):
"""Discord OAuth2 Redirect"""
@ -43,7 +43,7 @@ class DiscordOAuth2Client(OAuth2Client):
return response.json() or response.text
@MANAGER.source(kind=RequestKind.callback, name='discord')
@MANAGER.source(kind=RequestKind.callback, name='Discord')
class DiscordOAuth2Callback(OAuthCallback):
"""Discord OAuth2 Callback"""

View file

@ -7,7 +7,7 @@ from passbook.oauth_client.utils import user_get_or_create
from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect
@MANAGER.source(kind=RequestKind.redirect, name='facebook')
@MANAGER.source(kind=RequestKind.redirect, name='Facebook')
class FacebookOAuthRedirect(OAuthRedirect):
"""Facebook OAuth2 Redirect"""
@ -17,7 +17,7 @@ class FacebookOAuthRedirect(OAuthRedirect):
}
@MANAGER.source(kind=RequestKind.callback, name='facebook')
@MANAGER.source(kind=RequestKind.callback, name='Facebook')
class FacebookOAuth2Callback(OAuthCallback):
"""Facebook OAuth2 Callback"""

View file

@ -7,7 +7,7 @@ from passbook.oauth_client.utils import user_get_or_create
from passbook.oauth_client.views.core import OAuthCallback
@MANAGER.source(kind=RequestKind.callback, name='github')
@MANAGER.source(kind=RequestKind.callback, name='GitHub')
class GitHubOAuth2Callback(OAuthCallback):
"""GitHub OAuth2 Callback"""

View file

@ -6,7 +6,7 @@ from passbook.oauth_client.utils import user_get_or_create
from passbook.oauth_client.views.core import OAuthCallback, OAuthRedirect
@MANAGER.source(kind=RequestKind.redirect, name='google')
@MANAGER.source(kind=RequestKind.redirect, name='Google')
class GoogleOAuthRedirect(OAuthRedirect):
"""Google OAuth2 Redirect"""
@ -16,7 +16,7 @@ class GoogleOAuthRedirect(OAuthRedirect):
}
@MANAGER.source(kind=RequestKind.callback, name='google')
@MANAGER.source(kind=RequestKind.callback, name='Google')
class GoogleOAuth2Callback(OAuthCallback):
"""Google OAuth2 Callback"""

View file

@ -17,17 +17,23 @@ class SourceTypeManager:
"""Manager to hold all Source types."""
__source_types = {}
__names = []
def source(self, kind, name):
"""Class decorator to register classes inline."""
def inner_wrapper(cls):
if kind not in self.__source_types:
self.__source_types[kind] = {}
self.__source_types[kind][name] = cls
self.__source_types[kind][name.lower()] = cls
self.__names.append(name)
LOGGER.debug("Registered source '%s' for '%s'", cls.__name__, kind)
return cls
return inner_wrapper
def get_name_tuple(self):
"""Get list of tuples of all registered names"""
return [(x.lower(), x) for x in set(self.__names)]
def find(self, source, kind):
"""Find fitting Source Type"""
if kind in self.__source_types:

View file

@ -29,7 +29,7 @@ class TwitterOAuthClient(OAuthClient):
return response.json() or response.text
@MANAGER.source(kind=RequestKind.callback, name='twitter')
@MANAGER.source(kind=RequestKind.callback, name='Twitter')
class TwitterOAuthCallback(OAuthCallback):
"""Twitter OAuth2 Callback"""