Exemple #1
0
    def post(self):
        try:
            token = self.get_argument("authkey", None)
            language = self.get_argument("language", settings.DEFAULT_LANGUAGE)

            login = self.get_argument("login", None)
            password = self.get_argument("password", None)

            if language not in settings.LANGUAGES:
                language = settings.DEFAULT_LANGUAGE

            if token is not None:
                session_token = FMAuth.authenticate_by_token(self, token)
                if session_token:
                    FMLocale.set_language(self, language, session_token)
                    if self.is_ajax():
                        self.json({'error': False, 'url': '/'})
                    else:
                        self.redirect('/')
                else:
                    if self.is_ajax():
                        self.json({
                            'error':
                            True,
                            'message':
                            self.get_user_locale().translate(
                                "Incorrect security token")
                        })
                    else:
                        self.redirect('/')
            else:
                session_token = FMAuth.authenticate_by_pam(
                    self, login, password)
                if session_token:
                    FMLocale.set_language(self, language, session_token)
                    if self.is_ajax():
                        self.json({'error': False, 'url': '/'})
                    else:
                        self.redirect('/')
                else:
                    if self.is_ajax():
                        self.json({
                            'error':
                            True,
                            'message':
                            self.get_user_locale().translate(
                                "Incorrect login or password")
                        })
                    else:
                        self.redirect('/')

            self.finish()

        except Exception as e:
            self.application.logger.error('In AuthHandler Exception: ' +
                                          str(e))
            raise tornado.web.HTTPError(403, "Authentication Failed")
Exemple #2
0
    def get(self):
        language = self.get_argument("language", DEFAULT_LANGUAGE)
        if language not in LANGUAGES:
            language = DEFAULT_LANGUAGE

        FMLocale.set_language(self, language)

        if self.application.options.debug:
            self.render("login.html", language=language)
        else:
            self.render("login.html", language=language)
Exemple #3
0
    def get(self):
        language = self.get_argument("language", None)
        if language is not None:
            secure_cookie = self.get_secure_cookie(settings.DEFAULT_COOKIE_TOKEN_NAME)
            auth_key = bytes.decode(secure_cookie)

            if language not in settings.LANGUAGES:
                language = settings.DEFAULT_LANGUAGE

            FMLocale.set_language(self, language, auth_key)
        if self.application.options.debug:
            self.render("app.debug.html", language=self.get_current_language())
        else:
            self.render("app.html", language=self.get_current_language())
    def get(self):
        language = self.get_argument("language", None)
        if language is not None:
            secure_cookie = self.get_secure_cookie(
                settings.DEFAULT_COOKIE_TOKEN_NAME)
            auth_key = bytes.decode(secure_cookie)

            if language not in settings.LANGUAGES:
                language = settings.DEFAULT_LANGUAGE

            FMLocale.set_language(self, language, auth_key)
        if self.application.options.debug:
            self.render("app.debug.html", language=self.get_current_language())
        else:
            self.render("app.html", language=self.get_current_language())
Exemple #5
0
    def post(self):
        try:
            token = self.get_argument("authkey", None)
            language = self.get_argument("language", settings.DEFAULT_LANGUAGE)

            login = self.get_argument("login", None)
            password = self.get_argument("password", None)

            if language not in settings.LANGUAGES:
                language = settings.DEFAULT_LANGUAGE

            if token is not None:
                session_token = FMAuth.authenticate_by_token(self, token)
                if session_token:
                    FMLocale.set_language(self, language, session_token)
                    self.json({
                        'error': False,
                        'url': '/'
                    })
                else:
                    self.json({
                        'error': True,
                        'message': self.get_user_locale().translate("Incorrect security token")
                    })
            else:
                session_token = FMAuth.authenticate_by_pam(self, login, password)
                if session_token:
                    FMLocale.set_language(self, language, session_token)
                    self.json({
                        'error': False,
                        'url': '/'
                    })
                else:
                    self.json({
                        'error': True,
                        'message': self.get_user_locale().translate("Incorrect login or password")
                    })

            self.finish()

        except Exception as e:
            self.application.logger.error('In AuthHandler Exception: ' + str(e))
            raise tornado.web.HTTPError(403, "Authentication Failed")
Exemple #6
0
    def get(self):
        try:
            token = self.get_argument("token", None)
            language = self.get_argument("language", settings.DEFAULT_LANGUAGE)

            if language not in settings.LANGUAGES:
                language = settings.DEFAULT_LANGUAGE

            if token is not None:
                session_token = FMAuth.authenticate_by_token(self, token)
                if session_token:
                    FMLocale.set_language(self, language, session_token)
                    self.redirect('/')
                else:
                    raise Exception("Session key is not exist")
            raise Exception("Session key is not provided")

        except Exception as e:
            self.application.logger.error('In AuthHandler Exception: ' + str(e))
            raise tornado.web.HTTPError(403, "Authentication Failed")