Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b961f28
commit 1827c2e
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
from evennia.objects.models import ObjectDB | ||
from evennia.comms.models import ChannelDB | ||
from evennia.commands import cmdhandler | ||
from evennia.server.models import ServerConfig | ||
from evennia.server.models import ServerConfig, Host | ||
from evennia.server.throttle import Throttle | ||
from evennia.utils import class_from_module, create, logger | ||
from evennia.utils.utils import (lazy_property, to_str, | ||
|
@@ -515,6 +515,10 @@ def authenticate(cls, username, password, ip='', **kwargs): | |
|
||
return None, errors | ||
|
||
# Record Host and login. | ||
host, created = Host.objects.get_or_create(ip=ip) | ||
account.login_records.create(source=host, date=time.time()) | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
volundmush
Author
Contributor
|
||
# Account successfully authenticated | ||
logger.log_sec('Authentication Success: %s (IP: %s).' % (account, ip)) | ||
return account, errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,3 +170,12 @@ def __uid_set(self, value): | |
def __uid_del(self): | ||
raise Exception("User id cannot be deleted!") | ||
uid = property(__uid_get, __uid_set, __uid_del) | ||
|
||
|
||
class Login(models.Model): | ||
""" | ||
Model for tracking Account logins. | ||
""" | ||
account = models.ForeignKey(AccountDB, related_name='login_records', on_delete=models.CASCADE) | ||
source = models.ForeignKey('server.Host', related_name='account_logins', on_delete=models.CASCADE) | ||
date = models.DateTimeField(null=False, db_index=True) | ||
This comment has been minimized.
Sorry, something went wrong.
strikaco
Contributor
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You ought to be using django.utils.timezone.now() for capturing timestamps, or set Host.date(auto_now_add=True) to grab them in UTC automatically.