From 0d5ec0bff29e5121a4082ed748a9a78364187853 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 21 Dec 2019 14:36:48 +0000 Subject: [PATCH] Add ssh key field --- users/forms.py | 1 + users/migrations/0085_user_ssh_key.py | 20 +++++++++++++++++++ users/models.py | 2 ++ users/templates/users/profil.html | 28 +++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 users/migrations/0085_user_ssh_key.py diff --git a/users/forms.py b/users/forms.py index cef1e43a..9fcb1e8c 100644 --- a/users/forms.py +++ b/users/forms.py @@ -449,6 +449,7 @@ class AdherentEditForm(AdherentForm): "shell", "gpg_fingerprint", "shortcuts_enabled", + "ssh_key", ] diff --git a/users/migrations/0085_user_ssh_key.py b/users/migrations/0085_user_ssh_key.py new file mode 100644 index 00000000..efeaf462 --- /dev/null +++ b/users/migrations/0085_user_ssh_key.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.23 on 2019-12-21 12:55 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0084_auto_20191120_0159'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='ssh_key', + field=models.TextField(blank=True, verbose_name='Public ssh key'), + ), + ] diff --git a/users/models.py b/users/models.py index ba15354b..5dfa352d 100755 --- a/users/models.py +++ b/users/models.py @@ -224,6 +224,7 @@ class User( shortcuts_enabled = models.BooleanField( verbose_name=_("enable shortcuts on Re2o website"), default=True ) + ssh_key = models.TextField(blank=True, verbose_name=_("Public ssh key")) USERNAME_FIELD = "pseudo" REQUIRED_FIELDS = ["surname", "email"] @@ -676,6 +677,7 @@ class User( self.surname.lower() + "_" + self.name.lower()[:3] ) user_ldap.gid = LDAP["user_gid"] + user_ldap.ssh_key = self.ssh_key if "{SSHA}" in self.password or "{SMD5}" in self.password: # We remove the extra $ added at import from ldap user_ldap.user_password = self.password[:6] + self.password[7:] diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 0bd25f75..6e5de11e 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -312,6 +312,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% trans "Shortcuts enabled" %}
{{ users.shortcuts_enabled | tick }}
+
+
{% trans "SSH key" %}
+
+ {% if users.ssh_key %} + + {% else %} + {% trans "No public SSH key" %} + {% endif %} +
+
@@ -541,5 +553,21 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %} + {% endblock %}