Home
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | {% extends 'base.html' %} {% block title %} {{user.username}}님의 마이페이지 {% endblock %} {% block content %} <div style="margin-top:5%;background-color:transparent; box-shadow: 4px 4px 4px 4px #1465AA;width:50%;margin-left:27%"> <header class="py-5"> <div class="container px-lg-5"> <div style="background-color:transparent; box-shadow: 2px 2px 2px 2px #1465AA;" class="p-4 p-lg-5 rounded-3 text-center"> <div class="m-4 m-lg-5"> <hr class='one'> <h2 class="fs-4 fw-bold">{{user.username}} 님 환영합니다!</h2> <a class="btn btn-primary btn-lg" href="{% url 'user:logout' %}">로그 아웃</a> </div> </div> </div> </header> <!-- Page Content--> <section class="pt-4"> <div class="container px-lg-5"> <!-- Page Features--> <div class="row gx-lg-5"> <div class="col-lg-12 col-xxl-4 mb-5"> <div style="background-color:transparent; box-shadow: 2px 2px 2px 2px #1465AA;" class="card border-0 h-100"> <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0"> <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-collection"></i></div> <hr class='one'> <p style="font-size:2em;margin-bottom: 2%;"class="mb-0">내가 작성한 글 </p> <h4 style="margin-top:5%;"><a href="{% url 'article:mypost' %}" class="ml-2">팀업게시판</a></h4> <h4><a href="{% url 'free:mypost' %}" class="ml-2">자유게시판</a></h4> </div> </div> </div> <div "class="col-lg-6 col-xxl-4 mb-5"> <!-- <div class="card bg-light border-0 h-100"> <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0"> <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-cloud-download"></i></div> <hr class='one'> <h2 class="fs-4 fw-bold"><a href="{% url 'free:mypost' %}" class="ml-2">내가 쓴 글</a></h2> <p class="mb-0">자유 게시판</p> </div> </div> --> </div> <div class="col-lg-6 col-xxl-4 mb-5"> <div style="background-color:transparent; box-shadow: 2px 2px 2px 2px #1465AA;" class="card border-0 h-100"> <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0"> <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-card-heading"></i></div> <hr class='one'> <h2 class="fs-4 fw-bold"><a href="{% url 'user:change_pw' %}" class="ml-2">비밀번호 변경</a></h2> <p class="mb-0"></p> </div> </div> </div> <div class="col-lg-6 col-xxl-4 mb-5"> <div style="background-color:transparent; box-shadow: 2px 2px 2px 2px #1465AA;" class="card border-0 h-100"> <div class="card-body text-center p-4 p-lg-5 pt-0 pt-lg-0"> <div class="feature bg-primary bg-gradient text-white rounded-3 mb-4 mt-n4"><i class="bi bi-code"></i></div> <hr class='one'> <h2 style="color:black;"><a href="{% url 'user:signout' %}" class="ml-2">회원 탈퇴</a></h2> <p class="mb-0"></p> </div> </div> </div> </div> </div> </section> <!-- Footer--> <!-- Bootstrap core JS--> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"></script> <!-- Core theme JS--> <script src="js/scripts.js"></script> </div> </div> {% endblock %} | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | from django.shortcuts import render, redirect from django.contrib.auth.hashers import check_password from .models import Normaluser from django.views.decorators.csrf import csrf_exempt from django.contrib import auth from django.contrib import messages from django.contrib.auth import update_session_auth_hash from django.contrib.auth.forms import PasswordChangeForm #회원가입 @csrf_exempt def register(request): if request.method == 'GET': return render(request, 'user/register.html') elif request.method == 'POST': username = request.POST['username'] password = request.POST['password'] re_password = request.POST['re_password'] res_data = {} if not (username and password and re_password): res_data['error'] = "모든 값을 입력해야합니다." elif password != re_password: res_data['error'] = '비밀번호가 일치하지 않습니다' else: normaluser = Normaluser.objects.create_user( username=username, password=password ) normaluser.save() return render(request, 'main/home.html', res_data) return render(request, 'user/register.html', res_data) # 로그인 @csrf_exempt def login(request): if request.method == 'POST': username = request.POST["username"] password = request.POST["password"] normaluser = auth.authenticate(request, username=username, password=password) if normaluser is not None: auth.login(request, normaluser) return redirect('/') else: return render(request, 'user/login.html', {'error':'아이디 혹은 비밀번호가 다릅니다.'}) else: return render(request, 'user/login.html') # 로그아웃 def logout(request): if request.session.get('user'): del(request.session['user']) return redirect('/') def logout(request): auth.logout(request) return redirect('/') def mypage(request): return render(request, "user/mypage.html") # 비밀번호 변경 def change_pw(request): if request.method == 'POST': form = PasswordChangeForm(request.user, request.POST) if form.is_valid(): user = form.save() update_session_auth_hash(request, user) messages.success(request, 'Your password was successfully updated!') return redirect('/') else: messages.error(request, 'Please correct the error below.') else: form = PasswordChangeForm(request.user) return render(request, 'user/change_pw.html', { 'form': form }) # 회원 탈퇴 def userDelete(request): user = request.user user.delete() logout(request) context = {} return render(request, 'user/farewell.html', context) def signout(request): return render(request, 'user/signout.html') | cs |