def get_token_seed(self):
     if not 'token_seed' in self.storage.data:
         alias = '%s@%s' % (self.request.user.username,
                            get_current_site(self.request).name)
         seed = generate_seed()
         self.storage.data['token_seed'] = seed
         self.storage.data['extra_data']['qr_url'] = get_qr_url(alias, seed)
     return self.storage.data['token_seed']
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError('Provide a username as first argument')
        try:
            user = User.objects.get(username=args[0])
        except User.DoesNotExist:
            raise CommandError('User with username "%s" not found' % args[0])

        try:
            token = user.token
        except Token.DoesNotExist:
            token = Token(user=user)

        token.seed = generate_seed()
        token.save()

        print 'Updated seed for %s to: %s (hex)' % (user.username, token.seed)
        print ''
        print 'QR Code for Google Authenticator can be found here:'
        print ''
        print get_qr_url(user.username, token.seed)
        print ''
Пример #3
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError('Provide a username as first argument')
        try:
            user = User.objects.get(username=args[0])
        except User.DoesNotExist:
            raise CommandError('User with username "%s" not found' % args[0])

        try:
            token = user.token
        except Token.DoesNotExist:
            token = Token(user=user)

        token.seed = generate_seed()
        token.save()

        print 'Updated seed for %s to: %s (hex)' % (user.username, token.seed)
        print ''
        print 'QR Code for Google Authenticator can be found here:'
        print ''
        print get_qr_url(user.username, token.seed)
        print ''