~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wlggz/models.py

  • Committer: franku
  • Date: 2019-05-17 18:13:04 UTC
  • mfrom: (535.1.9 gaming_password)
  • Revision ID: somal@arcor.de-20190517181304-kws07wnuy3rzdfjr
reworked profile view; setting online gaming password is now double checked

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
from django.utils.translation import ugettext_lazy as _
14
14
from pybb.models import Post
15
15
 
 
16
import hashlib
 
17
import base64
16
18
 
17
19
class GGZAuth(models.Model):
18
20
    user = AutoOneToOneField(
24
26
    class Meta:
25
27
        verbose_name = _('ggz')
26
28
        verbose_name_plural = _('ggz')
 
29
 
 
30
    def save(self, *args, **kwargs):
 
31
        # hash the password
 
32
        pw_hash = hashlib.sha1(self.password.encode('utf-8')).digest()
 
33
        pw_base64 = base64.standard_b64encode(pw_hash)
 
34
        self.password = pw_base64
 
35
        # Save into the database
 
36
        super(GGZAuth, self).save(*args, **kwargs)