<commit_before>import tornado.web
import tornado.auth
import json
import requests

from status.util import UnsafeHandler, GoogleUser

class LoginHandler(tornado.web.RequestHandler, tornado.auth.GoogleOAuth2Mixin):
    @tornado.gen.coroutine
    def get(self):
        if self.get_argument("code", False):
            user_token =  yield self.get_authenticated_user(
                    redirect_uri='https://genomics-status.scilifelab.se/login',
                code=self.get_argument('code')
                )
            user = GoogleUser(user_token)
            user_view = self.application.gs_users_db.view("authorized/users", reduce=False)
            if user.authenticated and user.is_authorized(user_view):
                self.set_secure_cookie('user', user.display_name)
                url = '/'
            else:
                url = "/unauthorized?email={0}&contact={1}".format(user.emails[0],
                        self.application.settings['contact_person'])
            self.redirect(url)

        else:
            self.authorize_redirect(
                    redirect_uri='https://genomics-status.scilifelab.se/login',
                        client_id=self.application.oauth_key,
                        scope=['profile', 'email'],
                        response_type='code',<commit_msg>Save email for future personalized features<commit_after>import tornado.web
import tornado.auth
import json
import requests

from status.util import UnsafeHandler, GoogleUser

class LoginHandler(tornado.web.RequestHandler, tornado.auth.GoogleOAuth2Mixin):
    @tornado.gen.coroutine
    def get(self):
        if self.get_argument("code", False):
            user_token =  yield self.get_authenticated_user(
                    redirect_uri='http://localhost:9761/login',
                code=self.get_argument('code')
                )
            user = GoogleUser(user_token)
            user_view = self.application.gs_users_db.view("authorized/users", reduce=False)
            if user.authenticated and user.is_authorized(user_view):
                self.set_secure_cookie('user', user.display_name)
                #It will have at least one email (otherwise she couldn't log in)
                self.set_secure_cookie('email', user.emails[0])
                url = '/'
            else:
                url = "/unauthorized?email={0}&contact={1}".format(user.emails[0],
                        self.application.settings['contact_person'])
            self.redirect(url)

        else:
            self.authorize_redirect(
                    redirect_uri='http://localhost:9761/login',
                        client_id=self.application.oauth_key,
                        scope=['profile', 'email'],
                        response_type='code',
{'fraction_non_alphanumeric': 0.10387260224393775, 'fraction_numerical': 0.006152732537097358, 'mean_word_length': 2.0643015521064303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5865801', 'n_tokens_mistral': 764, 'n_tokens_neox': 720, 'n_words': 120}