def post(self):
        # パラメータの取得
        _email = self.get_argument("form-email", None)
        _raw_pass = self.get_argument("form-password", None)

        # エラーメッセージの初期化
        errors = []

        # 入力項目の必須チェック
        if _email == None or _raw_pass == None:
            if _email == None:
                errors.append("Sign in ID(Email Address) is required.")
            if _raw_pass == None: errors.append("Password is required.")
            self.render("signin.html", errors=errors, messages=[])
            return

        # 入力されたパスワードをsha224で一方向の暗号化
        _pass = hashlib.sha224(_raw_pass.encode()).hexdigest()

        # メールアドレスでユーザー情報を取得
        u = user.find_by_email(_email)

        # 認証(ユーザーが存在する & パスワードが一致する で認証OK)
        if u == None or _pass != u.attr["password"]:
            # 認証失敗
            errors.append(
                "Sorry, your ID(Email Address) or password cannot be recognized."
            )
            self.render("signin.html", errors=errors, messages=[])
            return

        # DBに保管されたユーザーIDを文字列化して暗号化Cookieに格納
        self.set_secure_cookie("user", str(u.attr["id"]))
        # 認証が必要なページへリダイレクト
        self.redirect("/")
    def post(self):
        _email = self.get_argument("form-email", None)
        _name = self.get_argument("form-name", None)
        _raw_pass = self.get_argument("form-password", None)

        errors = []
        if _email == None: errors.append("ID(Email Address) is required.")
        if _name == None: errors.append("Name is required.")
        if _raw_pass == None: errors.append("Password is required.")
        if len(errors) > 0:
            self.render("signup.html", errors=errors, messages=[])
            return

        _pass = hashlib.sha224(_raw_pass.encode()).hexdigest()
        u = user.find_by_email(_email)

        if u is not None:
            self.render("signup.html",
                        errors=["The ID(Email Address) cannot be used."],
                        messages=[])
            return

        u = user.build()
        u.attr["email"] = _email
        u.attr["name"] = _name
        u.attr["password"] = _pass
        u.save()

        self.redirect("/signin?message=%s" % tornado.escape.url_escape(
            "Sign up is complete. Please continue to sign in."))
    def post(self):
        _email = self.get_argument("form-email", None)
        _raw_pass = self.get_argument("form-password", None)

        errors = []

        if _email == None or _raw_pass == None:
            if _email == None:
                errors.append("Sign in ID(Email Address) is required.")
            if _raw_pass == None: errors.append("Password is required.")
            self.render("signin.html", errors=errors, messages=[])
            return

        _pass = hashlib.sha224(_raw_pass.encode()).hexdigest()
        u = user.find_by_email(_email)

        if u == None or _pass != u.attr["password"]:
            errors.append(
                "Sorry, your ID(Email Address) or password cannot be recognized."
            )
            self.render("signin.html", errors=errors, messages=[])
            return

        self.set_secure_cookie("user", str(u.attr["id"]))
        self.redirect("/")
Esempio n. 4
0
    def post(self):
        # パラメータの取得
        _email = self.get_argument("email", None)
        _genre = self.get_argument("sound", None)
        _sex = self.get_argument("sex", None)
        _age = self.get_argument("age", None)
        _artist_name = self.get_argument("artist_name", None)
        _raw_pass = self.get_argument("password", None)

        # 入力項目の必須チェック
        errors = []
        if _email == None:
            errors.append("ID(Email Address) is required.")
        if _genre == None:
            errors.append("Genre is required.")
        if _sex == None:
            errors.append("Sex is required.")
        if _age == None:
            errors.append("Age is required.")
        if _artist_name == None:
            errors.append("Artist's name is required.")
        if _raw_pass == None:
            errors.append("Password is required.")
        if len(errors) > 0:  # エラーはサインイン画面に渡す
            self.render("signupArtist.html", errors=errors, messages=[])
            return

        # 入力されたパスワードをsha224で一方向の暗号化
        _pass = hashlib.sha224(_raw_pass.encode()).hexdigest()

        # メールアドレスでユーザー情報を取得
        u = user.find_by_email(_email)

        # メールアドレスの重複を許可しない
        if u is not None:
            self.render("signupArtist.html",
                        errors=["The ID(Email Address) cannot be used."],
                        messages=[])
            return

        # ユーザー情報を保存
        u = user()
        u.attr["email"] = _email
        u.attr["genre"] = _genre
        u.attr["sex"] = _sex
        u.attr["fan_class"] = _age
        u.attr["artist_name"] = _artist_name
        u.attr["password"] = _pass
        u.save_artist()

        # サインイン画面へリダイレクト(サインイン完了の旨を添えて)
        self.redirect("/loginArtist?message=%s" % tornado.escape.url_escape(
            "Sign up is complete. Please continue to sign in."))
    def post(self):
        # パラメータの取得
        _email = self.get_argument("form-email", None)
        _name = self.get_argument("form-name", None)
        _raw_pass = self.get_argument("form-password", None)

        # 入力項目の必須チェック
        errors = []
        if _email == None: errors.append("ID(Email Address) is required.")
        if _name == None: errors.append("Name is required.")
        if _raw_pass == None: errors.append("Password is required.")
        if len(errors) > 0:  # エラーはサインイン画面に渡す
            self.render("signup.html", errors=errors, messages=[])
            return

        # 入力されたパスワードをsha224で一方向の暗号化
        _pass = hashlib.sha224(_raw_pass.encode()).hexdigest()

        # メールアドレスでユーザー情報を取得
        u = user.find_by_email(_email)

        # メールアドレスの重複を許可しない
        if u is not None:
            self.render("signup.html",
                        errors=["The ID(Email Address) cannot be used."],
                        messages=[])
            return

        # ユーザー情報を保存
        u = user.build()
        u.attr["email"] = _email
        u.attr["name"] = _name
        u.attr["password"] = _pass
        u.save()

        # サインイン画面へリダイレクト(サインイン完了の旨を添えて)
        self.redirect("/signin?message=%s" % tornado.escape.url_escape(
            "Sign up is complete. Please continue to sign in."))
 def test_find_by_email動作確認(self):
     u = user.find_by_email(self.u.attr["email"])
     self.assertTrue(type(u) is user)
     self.assertTrue(u.attr["id"] == 1)
     self.assertTrue(u.attr["email"] == self.u.attr["email"])