mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
Add ssh key field
This commit is contained in:
parent
9e87f796aa
commit
0d5ec0bff2
4 changed files with 51 additions and 0 deletions
|
@ -449,6 +449,7 @@ class AdherentEditForm(AdherentForm):
|
||||||
"shell",
|
"shell",
|
||||||
"gpg_fingerprint",
|
"gpg_fingerprint",
|
||||||
"shortcuts_enabled",
|
"shortcuts_enabled",
|
||||||
|
"ssh_key",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
20
users/migrations/0085_user_ssh_key.py
Normal file
20
users/migrations/0085_user_ssh_key.py
Normal file
|
@ -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'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -224,6 +224,7 @@ class User(
|
||||||
shortcuts_enabled = models.BooleanField(
|
shortcuts_enabled = models.BooleanField(
|
||||||
verbose_name=_("enable shortcuts on Re2o website"), default=True
|
verbose_name=_("enable shortcuts on Re2o website"), default=True
|
||||||
)
|
)
|
||||||
|
ssh_key = models.TextField(blank=True, verbose_name=_("Public ssh key"))
|
||||||
|
|
||||||
USERNAME_FIELD = "pseudo"
|
USERNAME_FIELD = "pseudo"
|
||||||
REQUIRED_FIELDS = ["surname", "email"]
|
REQUIRED_FIELDS = ["surname", "email"]
|
||||||
|
@ -676,6 +677,7 @@ class User(
|
||||||
self.surname.lower() + "_" + self.name.lower()[:3]
|
self.surname.lower() + "_" + self.name.lower()[:3]
|
||||||
)
|
)
|
||||||
user_ldap.gid = LDAP["user_gid"]
|
user_ldap.gid = LDAP["user_gid"]
|
||||||
|
user_ldap.ssh_key = self.ssh_key
|
||||||
if "{SSHA}" in self.password or "{SMD5}" in self.password:
|
if "{SSHA}" in self.password or "{SMD5}" in self.password:
|
||||||
# We remove the extra $ added at import from ldap
|
# We remove the extra $ added at import from ldap
|
||||||
user_ldap.user_password = self.password[:6] + self.password[7:]
|
user_ldap.user_password = self.password[:6] + self.password[7:]
|
||||||
|
|
|
@ -312,6 +312,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<dt>{% trans "Shortcuts enabled" %}</dt>
|
<dt>{% trans "Shortcuts enabled" %}</dt>
|
||||||
<dd>{{ users.shortcuts_enabled | tick }}</dd>
|
<dd>{{ users.shortcuts_enabled | tick }}</dd>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-6 col-xs-12">
|
||||||
|
<dt>{% trans "SSH key" %}</dt>
|
||||||
|
<dd>
|
||||||
|
{% if users.ssh_key %}
|
||||||
|
<button class="btn btn-default btn-xs" type="button" data-toggle="modal" data-target="#modalSSH">
|
||||||
|
{% trans "Show key" %}
|
||||||
|
</button>
|
||||||
|
{% else %}
|
||||||
|
{% trans "No public SSH key" %}
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -541,5 +553,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal fade" id="modalSSH" tabindex="-1" role="dialog" aria-labelledby="modalSSH">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">{% blocktrans with pseudo=users.pseudo %}SSH key of {{ pseudo }}{% endblocktrans %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" style="word-break:break-all;">
|
||||||
|
{{users.ssh_key}}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal"> {% trans "Close" %}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue