Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from test2.models.meta import Base
- from which model classes will inherit
- from sqlalchemy import (
- Column,
- Integer,
- Unicode, #<- will provide Unicode field
- UnicodeText, #<- will provide Unicode text field
- Text,
- )
- class Users(Base):
- __tablename__ = 'users'
- id = Column(Integer, primary_key=True)
- name = Column(Text, unique=True, nullable=False,default='admin')
- password = Column(Text, nullable=False,default='password')
- from pyramid.view import view_config
- from test2.models.services.userservice import UserServices
- from pyramid.httpexceptions import HTTPFound, HTTPNotFound
- from pyramid.security import remember,forget
- @view_config(route_name='auth',match_param='action=in',renderer='string',request_method='POST')
- @view_config(route_name='auth', match_param='action=out', renderer='string')
- def dashboard(request):
- username=request.POST.get('username')
- if username:
- user=UserServices.by_name(username)
- if user and user.verify_password(request.POST.get('password')):
- return HTTPFound(location=request.route_url('home'))
- else:
- headers=forget(request)
- else:
- #return HTTPNotFound
- headers=forget(request)
- return HTTPFound(location=request.route_url('home'),headers=headers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement