Exemple #1
0
    def post(self):
        user = Authenticate(self.request)
        if not user:
            return self.redirect("/")

        old_password = self.request.get("old_password")
        new_password = self.request.get("new_password")
        new_password_repeat = self.request.get("new_password_repeat")
        # TODO: Validate data
        if not new_password:
            return self.redirect(
                "/profile/change_password?message=regpasserror")

        if not old_password or not hashes.valid_pw(user.email, old_password,
                                                   user.pw_hash):
            return self.redirect(
                "/profile/change_password?message=wrongpassword")

        if not new_password == new_password_repeat:
            return self.redirect(
                "/profile/change_password?message=regpassrepeaterror")

        SetUserPassword(user, new_password)

        return self.redirect("/profile?message=passwordchanged")
Exemple #2
0
    def post(self):
        # Authenticate
        admin = AdminAuthenticate(self.request)

        username = self.request.get("username")
        password = self.request.get("password")

        # validate form
        if not username or not password:
            return self.redirect("/admin/login")

        adminFind = Admin.query().filter(Admin.name == username).get()
        if not adminFind:
            return self.redirect("/admin/login")

        adminFind = adminFind[0]
        pw_hash = adminFind.pw_hash
        # validate admin
        if not hashes.valid_pw(username, password, pw_hash):
            return self.redirect("/admin/login")

        # validation successful - set cookie headers
        admin_id = str(adminFind.key.id())
        secure_val = hashes.make_secure_val(admin_id)
        self.response.headers.add_header(
            'Set-Cookie', str('name_adm=%s; Path=/' % secure_val))
        return self.redirect("/admin/home")
Exemple #3
0
    def post(self):
        # Authenticate
        admin = AdminAuthenticate(self.request)

        username = self.request.get("username")
        password = self.request.get("password")

        # validate form
        if not username or not password:
        	return self.redirect("/admin/login")

        adminFind = Admin.query().filter(Admin.name==username).get()
        if not adminFind:
        	return self.redirect("/admin/login")

        adminFind = adminFind[0]
        pw_hash = adminFind.pw_hash
        # validate admin
        if not hashes.valid_pw(username, password, pw_hash):
            return self.redirect("/admin/login")

        # validation successful - set cookie headers
        admin_id = str(adminFind.key.id())
        secure_val = hashes.make_secure_val(admin_id)
        self.response.headers.add_header('Set-Cookie', str('name_adm=%s; Path=/' % secure_val))
        return self.redirect("/admin/home")
Exemple #4
0
    def post(self):
        # Login
        email = self.request.get("email")
        password = self.request.get("password")
        userFind = User.query().filter(User.email == email).get()

        if not userFind:
            return self.redirect("/")

        pw_hash = userFind.pw_hash
        if not password or not hashes.valid_pw(email, password, pw_hash):
            return self.redirect("/")

        SetLoginCookies(self, userFind)
        return self.redirect("/home")
Exemple #5
0
    def post(self):
        # Login
        email = self.request.get("email")
        password = self.request.get("password")
        userFind = User.query().filter(User.email==email).get()
        
        if not userFind:
            return self.redirect("/")
        
        pw_hash = userFind.pw_hash
        if not password or not hashes.valid_pw(email, password, pw_hash):
            return self.redirect("/")

        SetLoginCookies(self, userFind)
        return self.redirect("/home")
Exemple #6
0
    def post(self):
        user = Authenticate(self.request)
        if not user:
            return self.redirect("/")

        old_password = self.request.get("old_password")
        new_password = self.request.get("new_password")
        new_password_repeat = self.request.get("new_password_repeat")
        # TODO: Validate data
        if not new_password:
            return self.redirect("/profile/change_password?message=regpasserror")

        if not old_password or not hashes.valid_pw(user.email, old_password, user.pw_hash):
            return self.redirect("/profile/change_password?message=wrongpassword")

        if not new_password == new_password_repeat:
            return self.redirect("/profile/change_password?message=regpassrepeaterror")

        SetUserPassword(user, new_password)
        
        return self.redirect("/profile?message=passwordchanged")
Exemple #7
0
    def post(self):
        user = Authenticate(self.request)
        if user:
            return self.redirect("/")

        # get login params
        username = self.request.get("username")
        password = self.request.get("password")
        userFind = User.query(User.name == username).get()

        # validate
        if not userFind:
            return self.redirect("/")

        if not (username and password):
            return self.redirect("/login")

        # hash pw
        pw_hash = userFind.pw_hash
        if not password or not hashes.valid_pw(username, password, pw_hash):
            return self.redirect("/")

        SetLoginCookies(self, userFind)
        return self.redirect("/new")
    def post(self):
        user = Authenticate(self.request)
        if user:
            return self.redirect("/")

        # get login params
        username = self.request.get("username")
        password = self.request.get("password")
        userFind = User.query(User.name==username).get()

        # validate
        if not userFind:
            return self.redirect("/")

        if not (username and password):
            return self.redirect("/login")

        # hash pw
        pw_hash = userFind.pw_hash
        if not password or not hashes.valid_pw(username, password, pw_hash):
            return self.redirect("/")

        SetLoginCookies(self, userFind)
        return self.redirect("/new")