Exemple #1
0
    def post(self):
        user = db.session.query(User).filter(User.name == request.GET.get('name')).first()

        if not user:
            raise Unauthorized

        if not check_password(user):
            raise Unauthorized

        session.clear()
        session['user_id'] = user.id_
        return self.json(session.get_dictionary(), 201)
Exemple #2
0
    def post(self):
        user = db.session.query(User).filter(
            User.name == request.GET.get('name')).first()

        if not user:
            raise Unauthorized

        if not check_password(user):
            raise Unauthorized

        session.clear()
        session['user_id'] = user.id_
        return self.json(session.get_dictionary(), 201)
Exemple #3
0
    def post(self):
        form = SessionForm(**request.json)

        if not form.validate():
            raise BadRequest(form.errors)

        user = (db.session.query(User)
            .filter(User.email == form.email.data)
            .first())

        session.clear()
        session['user_id'] = user.id
        session.permanent = True
        return self.json(session.get_dictionary(), 201)
Exemple #4
0
    def post(self):
        user = db.session.query(User).filter(
            User.email == request.json.get('email')
        ).first()

        if not user:
            raise Unauthorized

        if not user.check_password(request.json.get('password')):
            raise Unauthorized

        session.clear()
        session['user_id'] = user.id_
        session.permanent = True
        return self.json(session.get_dictionary(), 201)
Exemple #5
0
 def index(self):
     if not session:
         return self.json({})
     return self.json(session.get_dictionary())
Exemple #6
0
 def index(self):
     return self.json(session.get_dictionary())
Exemple #7
0
 def index(self):
     return self.json(session.get_dictionary())