def get_user_and_login(self, email, raw_password): """ Takes an e-mail address and password and checks if a User exists with this combination. Updates date_last_login if user exists, None otherwise. """ password = get_hashed_password(raw_password) user = self._mk.User.find_one({'email':email, 'password':password}) if user is not None: user.date_last_login = get_unicode_datetime() user.save() return user
def make_user(self, name, email, raw_password): """ Takes in a user's information and makes a document in the table representing the user. Requires not user_exists(email). Returns the user. """ assert not self.user_exists(email), ( 'ASSERTION ERROR: User exists with email \'%s\'!' % email) new_user = self._mk.User() new_user.name = name new_user.email = email password = get_hashed_password(raw_password) new_user.password = password new_user.date_created = get_unicode_datetime() new_user.date_last_login = get_unicode_datetime() new_user.bookmark_sort_key = DEFAULT_BOOKMARK_SORT_KEY new_user.bookmark_sort_order = DEFAULT_BOOKMARK_SORT_ORDER new_user.save() return new_user