Exemplo n.º 1
0
    def check_or_create(self, token, auth_type):
        if auth_type == 'github':
            github = Github()
            user_info = github.get_user_info(token)
            user = User.objects(github_id=user_info['id']).first()

            if not user:
                user = User()
                email_github = github.get_email(token)

                user.token_github = token
                user.github = user_info['html_url']
                user.email = email_github[0]
                user.name = user_info['name']
                user.username = user_info['login']
                user.city = user_info['location']
                user.gravatar_id = user_info['gravatar_id']
                user.github_id = user_info['id']

                user.save()
                self.create_auth_session(user.id, token, auth_type)

            return self.create_auth_session(user.id, token, auth_type)
        else:
            return False
Exemplo n.º 2
0
    def check_or_create(self, token, auth_type):
        if auth_type == 'github':
            github = Github()
            user_info = github.get_user_info(token)
            user = User.objects(github_id=user_info['id']).first()
            
            if not user:
                user = User()
                email_github = github.get_email(token)
                
                user.token_github = token
                user.github = user_info['html_url']
                user.email = email_github[0]
                user.name = user_info['name']
                user.username = user_info['login']
                user.city     = user_info['location']
                user.gravatar_id = user_info['gravatar_id']
                user.github_id =user_info['id']

                user.save()
                self.create_auth_session(user.id, token, auth_type)

            return self.create_auth_session(user.id, token, auth_type)
        else:
            return False
Exemplo n.º 3
0
 def setUp(self):
     self.app = app.test_client()
     user = User(username='******',
                 email='*****@*****.**',
                 job='Test Job',
                 city='Test City',
                 name='Test Name',
                 github='Test github',
                 twitter='Test twitter',
                 linkedin='Test linkedin',
                 facebook='Test facebook',
                 googleplus='Test googleplus',
                 foursquare='Test foursquare',
                 personal_web='Test personal web')
     user = user.save()
     self.id = user.id
     self.username = user.username
Exemplo n.º 4
0
 def setUp(self):
     user = User(username='******',
                 email='Test email',
                 job='Test Job',
                 city='Test City',
                 name='Test Name',
                 github='Test github',
                 twitter='Test twitter',
                 linkedin='Test linkedin',
                 facebook='Test facebook',
                 github_id='12345',
                 gravatar_id='test gravatar id',
                 googleplus='Test googleplus',
                 foursquare='Test foursquare',
                 personal_web='Test personal web',
                 token_github='test github token')
     user = user.save()
     self.id = user.id
Exemplo n.º 5
0
 def setUp(self):
     self.app = app.test_client()
     user = User(
         username = '******',
         email = '*****@*****.**',
         job = 'Test Job',
         city = 'Test City',
         name = 'Test Name',
         github = 'Test github',
         twitter = 'Test twitter',
         linkedin = 'Test linkedin',
         facebook = 'Test facebook',
         googleplus = 'Test googleplus',
         foursquare = 'Test foursquare',
         personal_web =  'Test personal web'
         )
     user = user.save()
     self.id = user.id
     self.username = user.username