<commit_before># -*- coding: utf-8 -*-
import simplejson as json
from django.http import HttpResponse
from django.shortcuts import redirect, render, get_object_or_404, Http404
from django.conf import settings

from .models import UserActivation, User, AccessToken


def activate_user(request, code):
    ua = get_object_or_404(UserActivation, code=code)
    ua.user.is_active = True
    ua.user.save()
    return redirect(settings.DATEA_HOMEPAGE_URL)


def get_access_token(request, user_id):
        """Create a new Access Token for the user.

        """
        # self.method_check(request, allowed=['post'])

        query = User.objects.filter(pk=user_id)
        if query.exists():
            user = query.get()
        else:
            raise Http404("No User with such id: {0}".formar(user_id))

        access_token = AccessToken.new_token(user)<commit_msg>get_access_token verifies method and checks password<commit_after># -*- coding: utf-8 -*-
import simplejson as json
from django.http import (HttpResponse, HttpResponseNotAllowed,
                         HttpResponseForbidden, Http404, )
from django.shortcuts import redirect, render, get_object_or_404
from django.conf import settings

from .models import UserActivation, User, AccessToken


def activate_user(request, code):
    ua = get_object_or_404(UserActivation, code=code)
    ua.user.is_active = True
    ua.user.save()
    return redirect(settings.DATEA_HOMEPAGE_URL)


def get_access_token(request, user_id):
        """Create a new Access Token for the user.

        """
        if request.method not in ["POST"]:
            return HttpResponseNotAllowed

        query = User.objects.filter(pk=user_id)
        if query.exists():
            user = query.get()
        else:
            raise Http404("No User with such id: {0}".formar(user_id))

        if not user.check_password(request.META.get('X-PASSWORD', "")):
            HttpResponseForbidden(json.dumps({'error': 'Incorrect Password'}),
                                  mimetype='application/json')

        access_token = AccessToken.new_token(user)
{'fraction_non_alphanumeric': 0.10124164278892073, 'fraction_numerical': 0.013371537726838587, 'mean_word_length': 3.005736137667304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6776980', 'n_tokens_mistral': 636, 'n_tokens_neox': 603, 'n_words': 154}