def login(session, email, password): """<comment-ja> ログイン情報からユーザ情報を取得します。 @param session: Session @type session: sqlalchemy.orm.session.Session @param email: e-mail @type email: str @param password: パスワード @type password: str @return: karesansui.db.model.user.User </comment-ja> <comment-en> TODO: English Comment </comment-en> """ if email and password: _r = session.query(User).filter(User.email == email).first() if _r is None: return None if sha1compare(_r.password, password, _r.salt) is True: return _r else: return None return None
def compare_password(obj, user): checker = Checker() check = True _ = obj._ checker.errors = [] if not sha1compare(user.password, obj.input.password, user.salt): check = False checker.add_error(_('%s is mismatched.') % _('Current Password')) obj.view.alert = checker.errors return check