Commits

tjama  committed 4bfd100

fixes

  • Participants
  • Parent commits a2a7677

Comments (0)

Files changed (1)

             passwd = self.get_argument("passwd", default='')
             emptypass = ( passwd == '') 
             if (emptyuser or emptypass):
-                self.write(loader.load('login.html').generate(emptyuser=emptyuser, emptypass=emptypass, err=False))
+                self.write(loader.load('login.html').generate(user=self.get_current_user(), emptyuser=emptyuser, emptypass=emptypass, err=False))
                 return None    
             query = db.get("SELECT id, password FROM namethatanime_user where username = %s", (username,))
             ##print query
                         self.redirect("/")
                         return
             ## Wrong password
-            self.write(loader.load('login.html').generate(emptypass=False, emptyuser=False, err=True))
+            self.write(loader.load('login.html').generate(user=self.get_current_user(), emptypass=False, emptyuser=False, err=True))
         except Exception, e:
             ntae.process_exception(e, {'handler':'LoginHandler'})
 
             if self.get_argument("passwd", default='') != self.get_argument("passwd2", default=''):
                 dontmatch = True
             p = re.compile('(\w+)')
-            if p.match(username).group() != username:
+            matchres = p.match(username).group()
+            if matchres and matchres != username:
                 specchar = True
             if (emptypass or emptypass2 or emptyuser or emptyemail or dontmatch or specchar):
                 self.write(loader.load('registernew.html').generate(user=self.get_current_user(),specchar=specchar,emptypass=emptypass, emptypass2=emptypass2, emptyuser=emptyuser, emptyemail=emptyemail, dontmatch=dontmatch, username=username,email=email, useduser=useduser, usedemail=usedemail))
 class QuitGameHandler(BaseHandler):
     def get(self, game_id):
         try:
-            users[self.get_current_user().name]['game'].player_quit(users[self.get_current_user().name]['player'])
-            users[self.get_current_user().name].pop('player')
-            users[self.get_current_user().name].pop('game')
-            game = None
-            for g in games:
-                if str(id(g)) == game_id:
-                    game = g
-            if game != None:
-                if not game.players:
-                    games.remove(game)
-                    del game
+            if self.get_current_user():
+                users[self.get_current_user().name]['game'].player_quit(users[self.get_current_user().name]['player'])
+                users[self.get_current_user().name].pop('player')
+                users[self.get_current_user().name].pop('game')
+                game = None
+                for g in games:
+                    if str(id(g)) == game_id:
+                        game = g
+                if game != None:
+                    if not game.players:
+                        games.remove(game)
+                        del game
             self.redirect("/")
         except Exception, e:
             ntae.process_exception(e, {'handler':'QuitGameHandler'})