forked from avallbona/Impostor
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
5 changed files
with
203 additions
and
167 deletions.
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
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
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 |
---|---|---|
@@ -1,20 +1,30 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
#from django.contrib.auth.signals import user_logged_in, user_logged_outs | ||
import hashlib, time | ||
import hashlib | ||
import time | ||
|
||
# Create your models here. | ||
|
||
|
||
class ImpostorLog(models.Model): | ||
impostor = models.ForeignKey(User, related_name='impostor', db_index=True) | ||
imposted_as = models.ForeignKey(User, related_name='imposted_as', verbose_name='Logged in as', db_index=True) | ||
impostor_ip = models.GenericIPAddressField(verbose_name="Impostor's IP address", null=True, blank=True) | ||
logged_in = models.DateTimeField(auto_now_add=True, verbose_name='Logged on') | ||
# These last two will come into play with Django 1.3+, but are here now for easier migration | ||
logged_out = models.DateTimeField(null=True, blank=True) | ||
token = models.CharField(max_length=32, blank=True, db_index=True) | ||
impostor = models.ForeignKey(User, related_name='impostor', db_index=True) | ||
imposted_as = models.ForeignKey( | ||
User, | ||
related_name='imposted_as', | ||
verbose_name='Logged in as', | ||
db_index=True) | ||
impostor_ip = models.GenericIPAddressField( | ||
verbose_name="Impostor's IP address", null=True, blank=True) | ||
logged_in = models.DateTimeField( | ||
auto_now_add=True, verbose_name='Logged on') | ||
# These last two will come into play with Django 1.3+, but are here now | ||
# for easier migration | ||
logged_out = models.DateTimeField(null=True, blank=True) | ||
token = models.CharField(max_length=32, blank=True, db_index=True) | ||
|
||
def save(self, *args, **kwargs): | ||
if not self.token and self.impostor: | ||
self.token = hashlib.sha1(self.impostor.username+str(time.time())).hexdigest()[:32] | ||
super(ImpostorLog, self).save(*args, **kwargs) | ||
def save(self, *args, **kwargs): | ||
if not self.token and self.impostor: | ||
self.token = hashlib.sha1( | ||
self.impostor.username + str(time.time())).hexdigest()[:32] | ||
super(ImpostorLog, self).save(*args, **kwargs) |
Oops, something went wrong.