diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index 0692be641..b70bf8950 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -172,9 +172,13 @@ FIXTURE_DIRS = [os.path.join(BASE_DIR, 'fixtures'), ] REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. - 'DEFAULT_PERMISSION_CLASSES': [ - 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' - ], + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly', + ), + # 'DEFAULT_AUTHENTICATION_CLASSES': ( + # 'rest_framework.authentication.BasicAuthentication', + # 'rest_framework.authentication.SessionAuthentication', + # ), } # This setting is required to override the Django's main loop, when running in # development mode, such as ./manage runserver diff --git a/apps/static/img/logo.png b/apps/static/img/logo.png new file mode 100644 index 000000000..0d8ff20a6 Binary files /dev/null and b/apps/static/img/logo.png differ diff --git a/apps/templates/_foot_js.html b/apps/templates/_foot_js.html index 0517a5dbc..b610cb089 100644 --- a/apps/templates/_foot_js.html +++ b/apps/templates/_foot_js.html @@ -17,4 +17,36 @@ $("#"+s1).addClass('active'); $('#'+s1+' .'+s2).addClass('active'); } + + function getCookie(name) { + var cookieValue = null; + if (document.cookie && document.cookie !== '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) === (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; + } + + var csrftoken = getCookie('csrftoken'); + console.log(csrftoken) + + function csrfSafeMethod(method) { + // these HTTP methods do not require CSRF protection + return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); + } + + $.ajaxSetup({ + beforeSend: function(xhr, settings) { + if (!csrfSafeMethod(settings.type) && !this.crossDomain) { + xhr.setRequestHeader("X-CSRFToken", csrftoken); + } + } + }); \ No newline at end of file diff --git a/apps/templates/_user_profile.html b/apps/templates/_user_profile.html index f62bc6d28..4c2d07a48 100644 --- a/apps/templates/_user_profile.html +++ b/apps/templates/_user_profile.html @@ -7,7 +7,7 @@ - Admin + {{ request.user.name }} {{ role | default:'普通用户' }} diff --git a/apps/users/forms.py b/apps/users/forms.py index d1621728a..cc6b551c2 100644 --- a/apps/users/forms.py +++ b/apps/users/forms.py @@ -6,6 +6,19 @@ from django import forms from .models import User, UserGroup +# class UserLoginForm(ModelForm): +# class Meta: +# model = User +# fields = [ +# "email", "password" +# ] + + +class UserLoginForm(forms.Form): + username = forms.CharField(label='用户名', max_length=100) + password = forms.CharField(label='密码', widget=forms.PasswordInput, max_length=100) + + class UserAddForm(ModelForm): class Meta: model = User diff --git a/apps/users/templates/users/login.html b/apps/users/templates/users/login.html new file mode 100644 index 000000000..96a86e217 --- /dev/null +++ b/apps/users/templates/users/login.html @@ -0,0 +1,48 @@ +{% load static %} +{% load bootstrap %} + + + + + + + JumpServer + + {% include '_head_css_js.html' %} + + + + + +
+
+
+

+
+ {% if error %} +
{{ error }}
+ {% endif %} +

Welcome to Jumpserver

+
+ {% csrf_token %} +
+ +
+ +
+ +
+ + + +
Forgot password? +
+

Copyright Jumpserver.org Organization © 2014-2015

+
+
+ + {% include '_foot_js.html' %} + + + + \ No newline at end of file diff --git a/apps/users/templates/users/user_detail.html b/apps/users/templates/users/user_detail.html index eccbbf06c..88188c28e 100644 --- a/apps/users/templates/users/user_detail.html +++ b/apps/users/templates/users/user_detail.html @@ -62,8 +62,7 @@ - + @@ -134,12 +133,8 @@
- {% if user.is_active %} - - {% else %} - - {% endif %} -