Commit 0d5ec0bf authored by root's avatar root

Add ssh key field

parent 9e87f796
Pipeline #2343 passed with stage
in 3 minutes and 52 seconds
......@@ -449,6 +449,7 @@ class AdherentEditForm(AdherentForm):
"shell",
"gpg_fingerprint",
"shortcuts_enabled",
"ssh_key",
]
......
# -*- 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(
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:]
......
......@@ -312,6 +312,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<dt>{% trans "Shortcuts enabled" %}</dt>
<dd>{{ users.shortcuts_enabled | tick }}</dd>
</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>
</div>
</div>
......@@ -541,5 +553,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endfor %}
</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">&times;</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 %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment