NextCloud Integration
This commit is contained in:
parent
02ad7a9441
commit
5f4b10cb82
113 changed files with 18992 additions and 235 deletions
74
uncloud_auth/templates/account/email.html
Normal file
74
uncloud_auth/templates/account/email.html
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
{% extends "account/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block head_title %}{% trans "E-mail Addresses" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% trans "E-mail Addresses" %}</h1>
|
||||
{% if user.emailaddress_set.all %}
|
||||
<p>{% trans 'The following e-mail addresses are associated with your account:' %}</p>
|
||||
|
||||
<form action="{% url 'account_email' %}" class="email_list" method="post">
|
||||
{% csrf_token %}
|
||||
<fieldset class="blockLabels">
|
||||
|
||||
{% for emailaddress in user.emailaddress_set.all %}
|
||||
<div class="ctrlHolder">
|
||||
<label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">
|
||||
|
||||
<input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/>
|
||||
|
||||
{{ emailaddress.email }}
|
||||
{% if emailaddress.verified %}
|
||||
<span class="pl-2 verified">{% trans "Verified" %}</span>
|
||||
{% else %}
|
||||
<span class="pl-2 unverified">{% trans "Unverified" %}</span>
|
||||
{% endif %}
|
||||
{% if emailaddress.primary %}<span class="pl-2 primary">{% trans "Primary" %}</span>{% endif %}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="buttonHolder">
|
||||
<button class="btn btn-secendary" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button>
|
||||
<button class="btn btn-secendary" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button>
|
||||
<!-- <button class="btn btn-primary" type="submit" name="action_remove" >{% trans 'Remove' %}</button> -->
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{% else %}
|
||||
<p><strong>{% trans 'Warning:'%}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}</p>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<!-- {% if can_add_email %}
|
||||
<h2>{% trans "Add E-mail Address" %}</h2>
|
||||
|
||||
<form method="post" action="{% url 'account_email' %}" class="add_email">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button class="btn btn-primary" name="action_add" type="submit">{% trans "Add E-mail" %}</button>
|
||||
</form>
|
||||
{% endif %} -->
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block extra_body %}
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var message = "{% trans 'Do you really want to remove the selected e-mail address?' %}";
|
||||
var actions = document.getElementsByName('action_remove');
|
||||
if (actions.length) {
|
||||
actions[0].addEventListener("click", function(e) {
|
||||
if (! confirm(message)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
30
uncloud_auth/templates/account/email_confirm.html
Normal file
30
uncloud_auth/templates/account/email_confirm.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{% extends "account/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load account %}
|
||||
|
||||
{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% trans "Confirm E-mail Address" %}</h1>
|
||||
|
||||
{% if confirmation %}
|
||||
|
||||
{% user_display confirmation.email_address.user as user_display %}
|
||||
|
||||
<p>{% blocktrans with confirmation.email_address.email as email %}Please confirm that <a href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user {{ user_display }}.{% endblocktrans %}</p>
|
||||
|
||||
<form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
|
||||
{% csrf_token %}
|
||||
<button class="btn btn-primary" type="submit">{% trans 'Confirm' %}</button>
|
||||
</form>
|
||||
|
||||
{% else %}
|
||||
|
||||
{% url 'account_email' as email_url %}
|
||||
|
||||
<p>{% blocktrans %}This e-mail confirmation link expired or is invalid. Please <a href="{{ email_url }}">issue a new e-mail confirmation request</a>.{% endblocktrans %}</p>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
43
uncloud_auth/templates/account/login.html
Normal file
43
uncloud_auth/templates/account/login.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{% extends "account/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load account socialaccount %}
|
||||
|
||||
{% block head_title %}{% trans "Sign In" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3 class="font-weight-400 mb-4">Log In</h3>
|
||||
<form id="loginForm" method="POST" action="{% url 'account_login' %}">
|
||||
{% csrf_token %}
|
||||
{% if form.non_field_errors %}
|
||||
<div class="p-2 my-4">
|
||||
{{ form.non_field_errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label for="username">{% trans "Username" %}</label>
|
||||
<input type="text" class="form-control" name="login" id="username" {% if form.login.value != None %}value="{{ form.login.value }}"{% endif %} required placeholder="{% trans 'Enter Your Username' %}">
|
||||
{{ form.login.errors }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="loginPassword">{% trans "Password" %}</label>
|
||||
<input type="password" class="form-control" name="password" id="loginPassword" {% if form.password.value != None %}value="{{ form.password.value }}"{% endif %} required placeholder="{% trans 'Enter Password' %}">
|
||||
{{ form.password.errors }}
|
||||
{% if redirect_field_value %}
|
||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<div class="form-check custom-control custom-checkbox">
|
||||
<input id="remember-me" name="remember" class="custom-control-input" type="checkbox" {% if form.password.value != None %}value="{{ form.password.value }}"{% endif %}>
|
||||
<label class="custom-control-label" for="remember-me">{% trans "Remember Me" %}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm text-right"><a class="btn-link" href="{% url 'account_reset_password' %}">{% trans "Forgot Password ?" %}</a></div>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-block my-4" type="submit">{% trans "Login" %}</button>
|
||||
</form>
|
||||
<p class="text-3 text-center text-muted">{% trans "Don't have an account?" %}<a class="btn-link px-2" href="{{ signup_url }}">{% trans "Sign Up" %}</a></p>
|
||||
|
||||
{% endblock %}
|
||||
18
uncloud_auth/templates/account/logout.html
Normal file
18
uncloud_auth/templates/account/logout.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{% extends "account/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block head_title %}{% trans "Sign Out" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3 class="font-weight-400 mb-4">{% trans "Sign Out" %}</h3>
|
||||
<p class="text-3 text-center text-muted">{% trans 'Are you sure you want to sign out?' %}</p>
|
||||
<form id="signoutForm" method="POST" action="{% url 'account_logout' %}">
|
||||
{% csrf_token %}
|
||||
{% if redirect_field_value %}
|
||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
|
||||
{% endif %}
|
||||
<button class="btn btn-primary btn-block my-4" type="submit">{% trans 'Sign Out' %}</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
29
uncloud_auth/templates/account/password_reset.html
Normal file
29
uncloud_auth/templates/account/password_reset.html
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{% extends "account/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load account %}
|
||||
|
||||
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if user.is_authenticated %}
|
||||
{% include "account/snippets/already_logged_in.html" %}
|
||||
{% endif %}
|
||||
<p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}</p>
|
||||
<form id="resetForm" method="POST" action="{% url 'account_reset_password' %}" class="password_reset">
|
||||
{% csrf_token %}
|
||||
{% if form.non_field_errors %}
|
||||
<div class="p-2 my-4">
|
||||
{{ form.non_field_errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label for="email">{% trans "Email" %}</label>
|
||||
<input type="text" class="form-control" name="email" id="email" {% if form.email.value != None %}value="{{ form.email.value }}"{% endif %} required placeholder="{% trans 'Enter Your Email' %}">
|
||||
{{ form.email.errors }}
|
||||
</div>
|
||||
<button class="btn btn-primary btn-block my-4" type="submit">{% trans 'Reset My Password' %}</button>
|
||||
<p class="text-4 text-center text-muted">{% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %}</p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
37
uncloud_auth/templates/account/password_reset_from_key.html
Normal file
37
uncloud_auth/templates/account/password_reset_from_key.html
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{% extends "account/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% block head_title %}{% trans "Change Password" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}</h1>
|
||||
|
||||
{% if token_fail %}
|
||||
{% url 'account_reset_password' as passwd_reset_url %}
|
||||
<p>{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a <a href="{{ passwd_reset_url }}">new password reset</a>.{% endblocktrans %}</p>
|
||||
{% else %}
|
||||
{% if form %}
|
||||
<form method="POST" action="{{ action_url }}">
|
||||
{% csrf_token %}
|
||||
{% if form.non_field_errors %}
|
||||
<div class="p-2 my-4">
|
||||
{{ form.non_field_errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label for="password1">{% trans "New Password (again)" %}</label>
|
||||
<input type="password" class="form-control" name="password1" id="password1" {% if form.password1.value != None %}value="{{ form.password1.value }}"{% endif %} required placeholder="{% trans 'New Passowrd' %}">
|
||||
{{ form.login.errors }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password2">{% trans "New Password" %}</label>
|
||||
<input type="password" class="form-control" name="password2" id="password2" {% if form.password2.value != None %}value="{{ form.password2.value }}"{% endif %} required placeholder="{% trans 'New Passowrd (again)' %}">
|
||||
{{ form.login.errors }}
|
||||
</div>
|
||||
<input class="btn btn-primary" type="submit" name="action" value="{% trans 'change password' %}"/>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>{% trans 'Your password is now changed.' %}</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
57
uncloud_auth/templates/account/signup.html
Normal file
57
uncloud_auth/templates/account/signup.html
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{% extends "account/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load account socialaccount %}
|
||||
|
||||
{% block head_title %}{% trans "Sign Up" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3 class="font-weight-400 mb-4">{% trans "Sign Up" %}</h3>
|
||||
<form id="signup_form" method="post" action="{% url 'account_signup' %}">
|
||||
{% csrf_token %}
|
||||
{% if form.non_field_errors %}
|
||||
<div class="p-2 my-4">
|
||||
{{ form.non_field_errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label for="username">{% trans "Username" %}</label>
|
||||
<input type="text" class="form-control" name="username" id="username" {% if form.username.value != None %}value="{{ form.username.value }}"{% endif %} required placeholder="{% trans 'Enter Username' %}">
|
||||
{{ form.username.errors }}
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="first_name">{% trans "First Name" %}</label>
|
||||
<input id="first_name" name="first_name" type="text" class="form-control" {% if form.first_name.value != None %}value="{{ form.first_name.value }}"{% endif %}placeholder="{% trans 'First Name' %}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="first_name">{% trans "Last Name" %}</label>
|
||||
<input id="last_name" name="last_name" type="text" class="form-control" {% if form.last_name.value != None %}value="{{ form.last_name.value }}"{% endif %}placeholder="{% trans 'Last Name' %}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">{% trans "E-mail" %}</label>
|
||||
<input type="text" class="form-control" name="email" id="email" {% if form.email.value != None %}value="{{ form.email.value }}"{% endif %} placeholder="{% trans 'Enter Email Address' %}">
|
||||
{{ form.email.errors }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password1">{% trans "Password" %}</label>
|
||||
<input type="password" class="form-control" name="password1" id="password1" {% if form.password1.value != None %}value="{{ form.password1.value }}"{% endif %} required placeholder="{% trans 'Enter Password' %}">
|
||||
{{ form.password1.errors }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password2">{% trans "Password" %}</label>
|
||||
<input type="password" class="form-control" name="password2" id="password2" {% if form.password2.value != None %}value="{{ form.password2.value }}"{% endif %} required placeholder="{% trans 'Password (again)' %}">
|
||||
{{ form.password2.errors }}
|
||||
{% if redirect_field_value %}
|
||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<button class="btn btn-primary btn-block my-4" type="submit">{% trans "Sign Up" %}</button>
|
||||
</form>
|
||||
<p class="text-3 text-center text-muted">{% trans "Already have an account?" %}<a class="btn-link px-2" href="{{ login_url }}">{% trans "Login" %}</a></p>
|
||||
{% endblock %}
|
||||
|
|
@ -2,6 +2,7 @@ import base64
|
|||
import hashlib
|
||||
import logging
|
||||
import random
|
||||
import unicodedata
|
||||
|
||||
import ldap3
|
||||
from ldap3 import ALL
|
||||
|
|
@ -108,7 +109,7 @@ class LdapManager:
|
|||
"uidNumber": [str(uidNumber)],
|
||||
"gidNumber": [str(settings.LDAP_CUSTOMER_GROUP_ID)],
|
||||
"loginShell": ["/bin/bash"],
|
||||
"homeDirectory": ["/home/{}".format(username).encode("utf-8")],
|
||||
"homeDirectory": ["/home/{}".format(unicodedata.normalize('NFKD', username).encode('ascii','ignore'))],
|
||||
"mail": email.encode("utf-8"),
|
||||
"userPassword": [self._ssha_password(password.encode("utf-8"))]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue