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 test_save_INSERT(self): f = user.build() f.attr["name"] = "HogeHuga" f.attr["password"] = "******" result = f.save() self.assertTrue(type(result) is int) self.assertTrue(f.attr["id"] is not None)
def post(self): # パラメータの取得 _name = self.get_argument("form-name", None) _raw_pass = self.get_argument("form-password", None) # 入力項目の必須チェック errors = [] 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_name(_name) # メールアドレスの重複を許可しない if u is not None: self.render("signup.html", errors=["The ID(name) cannot be used."], messages=[]) return # ユーザー情報を保存 u = user.build() 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_save_INSERT(self): u = user.build() u.attr["email"] = "*****@*****.**" u.attr["name"] = "Hoge" u.attr["password"] = "******" result = u.save() self.assertTrue(type(result) is int) self.assertTrue(u.attr["id"] is not None)
def test_save_UPDATE(self): f = user.build() f.attr["id"] = 1 f.attr["name"] = "new_Hoge" f.attr["password"] = "******" result = f.save() self.assertTrue(type(result) is int) self.assertTrue(f.attr["id"] is not None)
def test_db_save_insert(self): u = user.build() u.attr["id"] = None u.attr["email"] = "*****@*****.**" u.attr["name"] = "Hoge" u.attr["password"] = "******" result = u.save() self.assertTrue(type(result) is int)
def test_save_UPDATE(self): u = user.build() u.attr["id"] = 1 u.attr["email"] = "*****@*****.**" u.attr["name"] = "new_Hoge" u.attr["password"] = "******" result = u.save() self.assertTrue(type(result) is int) self.assertTrue(u.attr["id"] is not None)
def setUp(self): self.u = user.build() self.u.attr["email"] = "*****@*****.**" self.u.attr["name"] = "Hoge" self.u.attr["password"] = "******" self.patcher = mock.patch('model.project.project.name', return_value="test_user") self.mock_name = self.patcher.start() user.migrate() self.u.save()
def post(self): # パラメータの取得 _name = self.get_argument("form-name", None) _raw_pass = self.get_argument("form-password", None) # import pdb # pdb.set_trace() # 入力項目の必須チェック errors = [] if not _name: self.render("signup.html", errors="Nameを入力してください", messages=[]) if not _raw_pass: self.render("signup.html", errors="Passwordを入力してください", messages=[]) if len(errors) > 0: # エラーはサインイン画面に渡す self.render("signup.html") return if self.check_name(_name): if self.check_pass(_raw_pass): # 入力されたパスワードをsha224で一方向の暗号化 _pass = hashlib.sha224(_raw_pass.encode()).hexdigest() # nameでユーザー情報を取得 u = user.find_by_name(_name) # IDの重複を許可しない if u is not None: self.render("signup.html", errors=[ "そのユーザIDはすでに使われています"], messages=[]) return # ユーザー情報を保存 u = user.build() u.attr["user_name"] = _name u.attr["password"] = _pass u.save() # サインイン画面へリダイレクト(サインイン完了の旨を添えて) self.redirect("/signin?message=%s" % tornado.escape.url_escape( "ユーザ登録成功しました")) else: self.render("signup.html", errors="そのパスワードは登録できません", messages=[]) return else: self.render("signup.html", errors="そのユーザーIDは登録できません", messages=[]) return
def test_build(self): u = user.build() self.assertTrue(type(u) is user)
def test_build(self): f = user.build() self.assertTrue(type(f) is user)
def setUp(self): self.f = user.build() self.f.attr["name"] = "Hoge" self.f.attr["password"] = "******" user.migrate() self.f.save()