Show More
@@ -35,6 +35,7 b' from pylons import request, response, se' | |||
|
35 | 35 | import rhodecode.lib.helpers as h |
|
36 | 36 | from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator |
|
37 | 37 | from rhodecode.lib.base import BaseController, render |
|
38 | from rhodecode.model.db import User | |
|
38 | 39 | from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm |
|
39 | 40 | from rhodecode.model.user import UserModel |
|
40 | 41 | |
@@ -63,7 +64,7 b' class LoginController(BaseController):' | |||
|
63 | 64 | c.form_result = login_form.to_python(dict(request.POST)) |
|
64 | 65 | #form checks for username/password, now we're authenticated |
|
65 | 66 | username = c.form_result['username'] |
|
66 |
user = User |
|
|
67 | user = User.by_username(username, | |
|
67 | 68 | case_insensitive=True) |
|
68 | 69 | auth_user = AuthUser(user.user_id) |
|
69 | 70 | auth_user.set_authenticated() |
@@ -225,31 +225,31 b' class User(Base, BaseModel):' | |||
|
225 | 225 | def short_contact(self): |
|
226 | 226 | return '%s %s' % (self.name, self.lastname) |
|
227 | 227 | |
|
228 | ||
|
229 | 228 | @property |
|
230 | 229 | def is_admin(self): |
|
231 | 230 | return self.admin |
|
232 | 231 | |
|
233 | 232 | def __repr__(self): |
|
234 | return "<%s('id:%s:%s')>" % (self.__class__.__name__, | |
|
235 | self.user_id, self.username) | |
|
233 | try: | |
|
234 | return "<%s('id:%s:%s')>" % (self.__class__.__name__, | |
|
235 | self.user_id, self.username) | |
|
236 | except: | |
|
237 | return self.__class__.__name__ | |
|
236 | 238 | |
|
237 | 239 | @classmethod |
|
238 | def by_username(cls, username): | |
|
239 | return Session.query(cls).filter(cls.username == username).one() | |
|
240 | ||
|
240 | def by_username(cls, username, case_insensitive=False): | |
|
241 | if case_insensitive: | |
|
242 | return Session.query(cls).filter(cls.username.like(username)).one() | |
|
243 | else: | |
|
244 | return Session.query(cls).filter(cls.username == username).one() | |
|
241 | 245 | |
|
242 | 246 | def update_lastlogin(self): |
|
243 | 247 | """Update user lastlogin""" |
|
244 | 248 | |
|
245 | try: | |
|
246 | session = Session.object_session(self) | |
|
247 | self.last_login = datetime.datetime.now() | |
|
248 | session.add(self) | |
|
249 | session.commit() | |
|
250 | log.debug('updated user %s lastlogin', self.username) | |
|
251 | except (DatabaseError,): | |
|
252 | session.rollback() | |
|
249 | self.last_login = datetime.datetime.now() | |
|
250 | Session.add(self) | |
|
251 | Session.commit() | |
|
252 | log.debug('updated user %s lastlogin', self.username) | |
|
253 | 253 | |
|
254 | 254 | |
|
255 | 255 | class UserLog(Base, BaseModel): |
@@ -463,13 +463,13 b' class Repository(Base, BaseModel):' | |||
|
463 | 463 | |
|
464 | 464 | @property |
|
465 | 465 | def scm_instance(self): |
|
466 |
return self.__get_instance( |
|
|
466 | return self.__get_instance() | |
|
467 | 467 | |
|
468 | 468 | @property |
|
469 | 469 | def scm_instance_cached(self): |
|
470 | 470 | @cache_region('long_term') |
|
471 | 471 | def _c(repo_name): |
|
472 |
return self.__get_instance( |
|
|
472 | return self.__get_instance() | |
|
473 | 473 | |
|
474 | 474 | inv = self.invalidate |
|
475 | 475 | if inv: |
@@ -481,7 +481,7 b' class Repository(Base, BaseModel):' | |||
|
481 | 481 | |
|
482 | 482 | return _c(self.repo_name) |
|
483 | 483 | |
|
484 |
def __get_instance(self |
|
|
484 | def __get_instance(self): | |
|
485 | 485 | |
|
486 | 486 | repo_full_path = self.repo_full_path |
|
487 | 487 |
General Comments 0
You need to be logged in to leave comments.
Login now