Exemplo n.º 1
0
 def post(self, *m, **kw):
     try:
         if self.request.path == '/settings/profile':
             data = {
                 'displayname': self.get_argument('displayname',
                                                  default=''),
                 'avatar': self.get_argument('avatar', default='')
             }
             validate(data, self.profile_schema)
             self.current_user.displayname = data['displayname']
             self.current_user.avatar = data['avatar']
             self.session.add(self.current_user)
             self.session.commit()
             self.json_write('402')
             return
         elif self.request.path == '/settings/account':
             if not util.validpwd(self.get_argument('curpwd', default=''),
                                  self.current_user.pwd):
                 self.json_write('401')
                 return
             data = {'pwd': util.makepwd(self.get_argument('newpwd'))}
             self.current_user.pwd = data['pwd']
             self.session.add(self.current_user)
             self.session.commit()
             self.json_write('400')
             return
         elif self.request.path == '/settings/message':
             self.um.set_meta(self.current_user.uid, 'message-accept',
                              self.get_argument('msg', default='all'))
             self.json_write('404')
             return
         elif self.request.path == '/settings/email':
             return
     except ValueError:
         self.json_write('000')
Exemplo n.º 2
0
 def post(self,*m,**kw):
     try:
         if self.request.path=='/settings/profile':
             data = {
                     'displayname' : self.get_argument('displayname', default=''),
                     'avatar' : self.get_argument('avatar', default='')
                     }
             validate(data,self.profile_schema)
             self.current_user.displayname = data['displayname']
             self.current_user.avatar = data['avatar']
             self.session.add(self.current_user)
             self.session.commit()
             self.json_write('402')
             return
         elif self.request.path=='/settings/account':
             if not util.validpwd(self.get_argument('curpwd',default=''),self.current_user.pwd):
                 self.json_write('401')
                 return
             data = {
                     'pwd' : util.makepwd(self.get_argument('newpwd'))
                    }
             self.current_user.pwd = data['pwd']
             self.session.add(self.current_user)
             self.session.commit()
             self.json_write('400')
             return
         elif self.request.path=='/settings/message':
             self.um.set_meta(self.current_user.uid, 'message-accept', self.get_argument('msg', default='all'))
             self.json_write('404')
             return
         elif self.request.path=='/settings/email':
             return
     except ValueError:
         self.json_write('000')
Exemplo n.º 3
0
 def post(self):
     i_email = self.get_argument("email")
     i_pwd = self.get_argument("password")
     if not i_email or not i_pwd:
         self.json_write('3')
         return
     query = self.session.query(User).filter_by(email=i_email)
     if query.count() == 0:
         self.json_write('2')
         return
     elif query.count() >= 0:
         if (util.validpwd(i_pwd, query.one().pwd)):
             self.set_secure_cookie('auth', i_email)
             self.json_write('1')
             self.redirect('/home')
             return
         else:
             self.json_write('0')
             return
     else:
         self.json_write('000')
         return
Exemplo n.º 4
0
Arquivo: base.py Projeto: filod/vixi
 def post(self):        
     i_email = self.get_argument("email")
     i_pwd = self.get_argument("password")
     if not i_email or not i_pwd:
         self.json_write('3')
         return
     query = self.session.query(User).filter_by(email = i_email)
     if query.count() == 0:
         self.json_write('2')
         return
     elif query.count() >= 0 :
         if(util.validpwd(i_pwd, query.one().pwd)):
             self.set_secure_cookie('auth',i_email)
             self.json_write('1')
             self.redirect('/home')
             return
         else:
             self.json_write('0')
             return
     else:
         self.json_write('000')
         return