Ubuntu

add main.html

{% extends 'layout.html' %}
{% block content %}
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
{{ request.user.username }} 님 안녕하세요.
<button type="submit" class="btn right" onclick="location.href='/logout/';">로그아웃</button>
</div>
</div>
</div>
{% endblock %}
......@@ -25,22 +25,33 @@
<div class="form-group">
<div class="col-md-12">
<label for="password"><span style="color:green;">비밀번호</span><h6 style="display:inline;"> - 비밀번호는 6자리 이상으로 설정되어야 합니다.</h6></label>
<label for="password"><span style="color:green;">비밀번호</span><h6 style="display:inline;"> - 비밀번호는 8자리 이상으로 설정되어야 합니다.</h6></label>
<input id="password" type="password" class="form-control" name="password" required>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="first_name"><span style="color:green;"></span></label>
<input id="first_name" type="first_name" class="form-control" name="first_name" required>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="last_name"><span style="color:green;">이름</span></label>
<input id="last_name" type="last_name" class="form-control" name="last_name" required>
</div>
</div>
<div class="form-group">
......
......@@ -10,7 +10,7 @@ import hashlib
import django
def index(request):
def main(request):
if request.user.is_authenticated:
return render(request, "main.html")
else:
......@@ -36,7 +36,7 @@ def login(request):
cog = cognito.Cognito()
cog.sign_in_admin(username=un, password=hashcode)
return redirect('/')
return redirect('/main')
else:
return render(request, "login.html", {
"message": "check id and password"
......@@ -47,9 +47,7 @@ def login(request):
def logout(request):
if request.user.is_authenticated:
django.contrib.auth.logout(request)
return redirect("/")
return redirect("/main")
def register(request):
Cog = cognito.Cognito()
if request.method == "POST":
......@@ -94,7 +92,7 @@ def register(request):
Cog.confirm_sign_up(username=request.POST['username']);
return redirect('/')
return redirect('/main')
else:
return render(request, 'register.html', {
"message": 'erroe!'
......
......@@ -20,8 +20,8 @@ from django.conf.urls.static import static
from django.conf.urls import include, url
urlpatterns = [
url(r'^admin/', admin.site.urls),
# url('',views.home, name='home'),
url('login/', blog.views.login, name='login'),
url('logout/', blog.views.logout, name='logout'),
url('register/', blog.views.register, name='register'),
url('main/',blog.views.main, name='main'),
url(r'^login/', blog.views.login, name='login'),
url(r'^logout/', blog.views.logout, name='logout'),
url(r'^register/', blog.views.register, name='register'),
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.
No preview for this file type
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
class LoginConfig(AppConfig):
name = 'login'
No preview for this file type
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
# Create your models here.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render,redirect
from django.contrib.auth.models import User
from django.contrib import auth
def signup(request):
if request.method=="POST":
if request.POST["password1"]==request.POST["password2"]:
user=User.objects.create_user(
username1=request.POST["username"],
password=request.POST["password1"]
)
auth.login(request,user)
return redirect('login')
return render(request,'signup.html')
return render(request,'signup.html')
def login(request):
if request.method=="POST":
username=request.POST['username']
password=request.POST['password']
user=auth.authenticate(request,username=username,password=password)
if user is not None:
auth.login(request,user)
return redirect('home')
else:
return render(request,'login.html',{'error':'error!'})
else:
return render(request,'login.html')
def logout(request):
auth.logout(request)
return redirect('home')
\ No newline at end of file
No preview for this file type