code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,170 @@
+import styled from "@emotion/styled";
+import IconStarFilled from "components/rating/icons/IconStarFilled";
+import IconStarHalf from "components/rating/icons/IconStarHalf";
+import IconStarOutlined from "components/rating/icons/IconStarOutlined";
+import { HTMLAttributes, useEffect, useState, useRef... | Unknown | 넵 맞습니다..! |
@@ -0,0 +1,85 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Button from "components/button/Button";
+
+interface Props {
+ imgSrcList: string[];
+}
+
+const RestaurantDetailImgSection: React.FC<Props> = ({ imgSrcList }) => {
+ const [currentImgIn... | Unknown | 앗 이미지 슬라이더를 구현하려다가 일단 PR부터 올렸는데, 해당 버튼은 그 과정에서 생긴 별 의미 없는 버튼입니다.. 삭제하도록 하겠습니다! |
@@ -0,0 +1,70 @@
+import styled from "@emotion/styled";
+import RestaurantDetailImgSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailImgSection";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+imp... | Unknown | 확인 감사합니다. 수정했습니다! |
@@ -0,0 +1,137 @@
+import styled from "@emotion/styled";
+import Rating from "components/rating/Rating";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import Button from "components/button/Button";
+import TextInput from "components... | Unknown | 발견 감사합니다! 수정했습니다. |
@@ -0,0 +1,137 @@
+import styled from "@emotion/styled";
+import Rating from "components/rating/Rating";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import Button from "components/button/Button";
+import TextInput from "components... | Unknown | 넵 좋습니다! 수정했습니다. |
@@ -0,0 +1,85 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Button from "components/button/Button";
+
+interface Props {
+ imgSrcList: string[];
+}
+
+const RestaurantDetailImgSection: React.FC<Props> = ({ imgSrcList }) => {
+ const [currentImgIn... | Unknown | 이미지 슬라이더는 아직 구현하지 않았지만, 일단 이미지 전환이 가능하도록 버튼은 만들어두었습니다! 지금은 버튼 보일 겁니다. |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restauran... | Unknown | 오.. 넵 다른 페이지도 메인이 되는 텍스트(맛집 이름, 단체 이름)은 `<h1 />`을 사용하도록 수정하겠습니다.
일단 맛집 상세 페이지에서는 맛집 이름을 `<h1 />` 태그로 수정 완료하였습니다. |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restauran... | Unknown | className을 모두 kebab case로 수정완료하였습니다! |
@@ -0,0 +1,120 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Rating from "components/rating/Rating";
+import IconEditFilledWhite from "components/icons/IconEditFilledWhite";
+import Link from "next/link";
+import dayjs from "dayjs";
+
+interface Pr... | Unknown | className을 모두 kebab case로 수정완료하였습니다! |
@@ -0,0 +1,120 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Rating from "components/rating/Rating";
+import IconEditFilledWhite from "components/icons/IconEditFilledWhite";
+import Link from "next/link";
+import dayjs from "dayjs";
+
+interface Pr... | Unknown | 오 넵 감사합니다. 해당 방식으로 수정 완료하였습니다! |
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import styled from "@emotion/styled";
import { css, Theme } from "@emotion/react";
import CheckIcon from "components/inputs/TextInput/CheckIcon";
-import { TConditionCheck } from "./types/TConditionCheck";
+import { TConditionCheck } from "component... | Unknown | 넵 수정했습니다! |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restauran... | Unknown | restaurantId를 받아올 때 `const restaurantId = query.restaurantId ?? 0;` 이렇게만 했더니 props로 넘겨줄 때 타입 에러가 떠서 저렇게 설정한건데, 현재는 `const restaurantId = (query.restaurantId ?? 0) as string;` 아예 이런 식으로 타입을 명시해주어서 props로 받아올 때에도 string으로만 받아오도록 수정했습니다! |
@@ -0,0 +1,18 @@
+import styled from "@emotion/styled";
+import RestaurantsReviewForm from "feature/restaurants/restaurantsReview/components/form/RestaurantsReviewForm";
+
+interface Props {
+ restaurantId: string;
+}
+
+const ViewRestaurantReviewCreate: React.FC<Props> = ({ restaurantId }) => {
+ return (
+ <Emot... | Unknown | [여기](https://github.com/SystemConsultantGroup/foodhub-frontend/pull/27#discussion_r1373127345)에서 이유를 설명하였고, 해당 부분 string으로만 받아오도록 수정했습니다! |
@@ -0,0 +1,170 @@
+import styled from "@emotion/styled";
+import IconStarFilled from "components/rating/icons/IconStarFilled";
+import IconStarHalf from "components/rating/icons/IconStarHalf";
+import IconStarOutlined from "components/rating/icons/IconStarOutlined";
+import { HTMLAttributes, useEffect, useState, useRef... | Unknown | 별점을 drag하여 입력할 수 있도록 추가적으로 구현하였는데, 데스크톱에서는 잘 되는데 모바일에서는 touchMove 이벤트가 중간에 끊기는 현상이 발생하였습니다. 정확히는 touchMove 도중에 state를 세팅하면, 터치는 이어지고 있는 상황인데도 touchMove가 인식되지 않습니다. selectedValue가 바뀌면서 star들이 다시 렌더링되는 것 때문인 것 같지만 정확히 뭐 때문인지는 모르겠습니다. 현재 해결 방안을 찾는 중이긴 한데, 하다가 안되면 이슈로 올리도록 하겠습니다.. @jaychang99 @hoon5083 |
@@ -0,0 +1,34 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.Secured;
+import org.aopalliance.intercept.MethodInvocation;
+
+import java.lang.reflect.Me... | Java | 조금 헷갈리실 수 있을 법한 부분이라고 생각해요. 두가지를 분리해놓고 생각해보면,
`SecuredAuthorizationManager`는 `@Secured` 어노테이션을 보고 인가 과정을 체크하는 것이고, `AuthorityAuthorizationManager `는 명확하게 인가 처리를 직접 처리하는 객체에요.
그래서 사실 어떻게보면 `SecuredAuthorizationManager`와 `AuthorityAuthorizationManager`는 분리되어있다기보다는 실제로는 `SecuredAuthorizationManager`가 `AuthorityAutho... |
@@ -1 +1,39 @@
# spring-security-authorization
+
+## 실습
+
+1. [x] GET /members/me 엔드포인트 구현 및 테스트 작성
+2. [x] 권한 검증 로직을 AuthorizationFilter로 리팩터링
+
+## 🚀 1단계 - AuthorizationManager를 활용
+
+요구사항
+
+- [x] AuthorizationManager 를 활용하여 인가 과정 추상화
+- [x] 인가를 처리해줄 AuthorizationManager 생성
+- [x] RequestMatcherDelegatingAuthoriza... | Unknown | 필요 요구사항 잘 정리해주셨네요 👍 |
@@ -1,24 +1,30 @@
package nextstep.app;
+import jakarta.servlet.http.HttpServletRequest;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authentication.BasicAuthenticationFilter;
import next... | Java | 적절하게 잘 추가해주셨네요 :) |
@@ -0,0 +1,25 @@
+package nextstep.security.authorization;
+
+public class AuthorizationDecision {
+
+ private static final AuthorizationDecision GRANTED = new AuthorizationDecision(true);
+ private static final AuthorizationDecision DENIED = new AuthorizationDecision(false);
+
+ private final boolean isGrante... | Java | 메소드로 정의할 수도 있지만 결국 동일한 객체를 여러번 생성하는 것이기 때문에 불변한 객체를 만들 수 있는 현재 상황이라면 단순히 상수로 만들고 재사용하는 것도 방법이 되겠네요 :) |
@@ -1,38 +1,28 @@
package nextstep.security.authorization;
-import nextstep.security.authentication.Authentication;
-import nextstep.security.context.SecurityContextHolder;
-import org.springframework.web.filter.OncePerRequestFilter;
-
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
i... | Java | 인가권한이 거절되었는데 `AuthenticationException`인 인증 에러가 발생하는 것이 맞을까요? |
@@ -0,0 +1,31 @@
+package nextstep.security.matcher;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod httpMethod;
+ private final String[] requestURIs;
+
+ public MvcRequest... | Java | 실제 spring security에서는 성능의 문제로 인해 stream 사용을 제한하고 있습니다.
https://github.com/spring-projects/spring-security/issues/7154 |
@@ -0,0 +1,34 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.Secured;
+import org.aopalliance.intercept.MethodInvocation;
+
+import java.lang.reflect.Me... | Java | 질문주신 내용에 답변 달아두었던 것처럼 `AuthoritiesAuthorizationManager`로 구현하는 것까지는 아니어도 인가부분에 대해서 `AuthorityAuthorizationManager`를 사용하는 것으로 변경해보면 좋을 것 같아요. |
@@ -0,0 +1,65 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.ForbiddenException;
+
+import java.util.Collection;
+import java.util.Set;
+
+public class ... | Java | ```suggestion
public class AuthorityAuthorizationManager implements AuthorizationManager<T> {
```
위에서 나열한 이유에서 사실 `HttpServletRequest`보다는 제네릭 타입을 활용하여 다른 곳에서 활용할 수 있게끔 하는 것이 좋겠죠. |
@@ -0,0 +1,18 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AccessDeniedException;
+import nextstep.security.authorization.AuthorizationDecision;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
... | Java | 선택사항에 나와있는 verify는 구현하지 않으셔도 되긴 하지만, check와 verify는 각각 어떤 상황에서 사용할 해야 좋은지 세준님의 의견은 어떠신가요? |
@@ -0,0 +1,18 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AccessDeniedException;
+import nextstep.security.authorization.AuthorizationDecision;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
... | Java | 최근 spring security 버전에서는 `check`는 deprecated되었습니다. `AuthorizationDecision`이 지금 만들어주신 것과 같이 구현체로 되어있고, 일반적으로 오픈소스들이 커질수록 단순하게 구현해두었던 구현체들을 추상화하는 형태로 개선해나가는데요.
그래서 최근 버전에서는 구현체를 반환하는 `check`를 그대로 사용하기보다는 deprecated해둔 뒤 이를 추상화한 `AuthorizationResult`를 반환하는 메소드를 추가하여 해당 메소드 사용을 권장하고 있습니다.
https://github.com/frantictic... |
@@ -0,0 +1,34 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.Secured;
+import org.aopalliance.intercept.MethodInvocation;
+
+import java.lang.reflect.Me... | Java | SecuredAuthorizationManager 에서 정확한 인가 처리를 AuthorityAuthorizationManager 를 위임하도록 할 수 있겠네요.
AuthorityAuthorizationManager에서도 제네릭을 통해 전달받은 파라미터에 따라서 다른 처리를 할 수 도 있을 것 같아요.
제가 이해한 내용을 정리하면 SecuredAuthorizationManager 는 인가에 필요한 값을 어노테이션 기반으로 동적으로 사용합니다.
하지만 SecuredAuthorizationManager 는 정확히 어떤 인가 작업을 할지는 관심이 없습니다. 그래... |
@@ -0,0 +1,25 @@
+package nextstep.security.authorization;
+
+public class AuthorizationDecision {
+
+ private static final AuthorizationDecision GRANTED = new AuthorizationDecision(true);
+ private static final AuthorizationDecision DENIED = new AuthorizationDecision(false);
+
+ private final boolean isGrante... | Java | AuthorizationDecision 에서 성공 실패만 가지고 있기 때문에 좋은 방법이네요. |
@@ -1,38 +1,28 @@
package nextstep.security.authorization;
-import nextstep.security.authentication.Authentication;
-import nextstep.security.context.SecurityContextHolder;
-import org.springframework.web.filter.OncePerRequestFilter;
-
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
i... | Java | Forbidden 으로 처리하도록 변경해야겠네요.
이 부분에서도 이쪽에서도 왜 check보다 verify를 권장하는 지 보여주는 것 같네요. AuthorizationDecision 인가 결과에 대한 처리에 일관성을 보장해주는 것이 필요해 보이네요! |
@@ -0,0 +1,31 @@
+package nextstep.security.matcher;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod httpMethod;
+ private final String[] requestURIs;
+
+ public MvcRequest... | Java | 성능 문제와 가독성은 언제나 고민이 되는 부분입니다.
요즘은 개발하면 Stream 을 가독성이 조금 더 좋다고 생각해서 선택하는 것 같네요.
말씀해주신 대로 ForEach 로 수정해보겠습니다! |
@@ -0,0 +1,34 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.Secured;
+import org.aopalliance.intercept.MethodInvocation;
+
+import java.lang.reflect.Me... | Java | 인가 부분을 위임하도록 변경해보았습니다! |
@@ -0,0 +1,65 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.ForbiddenException;
+
+import java.util.Collection;
+import java.util.Set;
+
+public class ... | Java | 필터와 인터셉터 혹은 인터셉터에서도 여러 종류 값을 사용하기 위해서 좋은 선택 같습니다,
그렇다면 AuthorityAuthorizationManager 는 여러 종류의 구현체를 만들어서 관리할 수 도 있을 것 같습니다.
예를 들어 RequestMatcherDelegatingAuthorizationManager 처럼 여러 구현체에 support 메서드나 Matcher를 만듭니다.
이를 통해 처리할 수 있는 인가 작업인지 확인하고 그에 맞는 AuthorityAuthorizationManager 구현체가 작동하는 방식으로 쉽게 관리 될 것 같아요! |
@@ -0,0 +1,18 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AccessDeniedException;
+import nextstep.security.authorization.AuthorizationDecision;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
... | Java | 제가 이 미션을 진행하면서 느낌 점은 세 가지입니다.
1. AuthorizationDecision 의 널의 위험성
2. AuthorizationDecision 가 실패됬을 때의 예외 처리 일관성
3. 사용도 안하는 결과를 리턴
이런 상황때문에 verify를 권장하는 것 같습니다.
하지만 AuthorizationDecision 의 결과를 커스텀 예외나 조건부 로직이 필요한 경우만 check을 사용해 결과를 핸들링 할 것 같습니다. |
@@ -0,0 +1,18 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AccessDeniedException;
+import nextstep.security.authorization.AuthorizationDecision;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
... | Java | 미션을 하다보니 말씀해주신 대로 AuthorizationDecision 가 deprecated된 이유가 간접적으로 느껴지는 것 같습니다.
RequestMatcherDelegatingAuthorizationManager 에서도 checkInFilter 보다는 verifyInFilter를 사용한다면
AuthorizationFilter 에서의 인가 요청, 예외처리 두가지 역할에서 인가 요청만 남게되어서 훨씬 깔끔합니다! |
@@ -0,0 +1,34 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.Secured;
+import org.aopalliance.intercept.MethodInvocation;
+
+import java.lang.reflect.Me... | Java | 네 이해해주신 내용이 맞습니다 :) |
@@ -0,0 +1,18 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AccessDeniedException;
+import nextstep.security.authorization.AuthorizationDecision;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
... | Java | 사실 spring security에서는 `verify`를 권장하는 것은 아니에요. (오해의 소지가 있을 수 있을 것 같아 미리 말씀드리면 정답을 요구하기 위해 남겨드린 질문은 아닙니다.)
말씀해주신 이유 중 먼저 1에 대해서 이야기하면 null 위험성을 발생시키는 것은 맞지만 `AuthorizationDecision`의 반환은 인가됨(true), 인가안됨(false)만 있는 것이 아니라 인가 상황이 없음을 나타내기도 합니다. 가령 `@Secured`가 걸린 곳이 없어 검증할 `authorities`가 없는 경우가 있겠네요.
```java
public Aut... |
@@ -0,0 +1,31 @@
+package nextstep.security.matcher;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod httpMethod;
+ private final String[] requestURIs;
+
+ public MvcRequest... | Java | 실제로는 `httpMethod`, `requestUri`각각 하나만을 가지므로 `String[]`으로 표현되진 않습니다. 딱 하나로 지정된 method, uri만을 검증하면 되는거죠.
여러개의 uri가 필요한 경우라면 필요한 객체가 `RequestMatcher`를 여러개로 들고 있는 형태가 더 자연스럽습니다 :) |
@@ -0,0 +1,25 @@
+package nextstep.security.authorization;
+
+public class AuthorizationDecision {
+
+ private static final AuthorizationDecision GRANTED = new AuthorizationDecision(true);
+ private static final AuthorizationDecision DENIED = new AuthorizationDecision(false);
+
+ private final boolean isGrante... | Java | 미션에서는 spring security의 기능이 축소되어 true, false가 잘 안와닿으실 수 있으나 실제로는 그보다 더 다양한 구현체들이 생길 수 있습니다.
https://github.com/spring-projects/spring-security/blob/main/core/src/main/java/org/springframework/security/authorization/AuthorityAuthorizationDecision.java |
@@ -0,0 +1,18 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AccessDeniedException;
+import nextstep.security.authorization.AuthorizationDecision;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
... | Java | 자세한 설명 감사합니다. 단순 인가 성공, 실패 뿐만 아니라 여러 케이스에 대해서는 깊이 생각 못했었는데, 고민해볼 포인트네요!
AuthorizationManager에서는 인가 확인, AuthorizationFilter 전체적인 맥락을 파악하여 필터링 해주는 것이군요! |
@@ -0,0 +1,31 @@
+package nextstep.security.matcher;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod httpMethod;
+ private final String[] requestURIs;
+
+ public MvcRequest... | Java | 하나의 Matcher에 하나의 URI 검증하는 것이 더 이해하기 좋겠네요! |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
... | JavaScript | 리액트 관련 라이브러리 import가 더 우선순위에 위치해야 할 것 같습니다! |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
... | JavaScript | import './Login.scss'; 위로 가야될 것 같습니다!! 😎 |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
... | JavaScript | 수정완료 😊 |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
... | JavaScript | - variable.scss 는 scss 파일에서 사용하는 것이기 때문에 js 에서 import 를 하는 것이 의미가 없습니다.
- scss 파일에서 변수를 사용하는 경우에 import 해주세요! |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
... | JavaScript | - 두 함수는 하는 역할이 비슷하기 때문에 충분히 하나의 함수로 합쳐볼 수 있을 것 같습니다.
- Refactoring CheckList 참고해서 수정해 보세요! |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
... | JavaScript | - isActive 는 id 와 pw 로 계산할 수 있는 값이이기 때문에 state 로 관리할 필요가 없어 보입니다!
- 아래 공식 문서 참고하셔서 어떤 값들이 state 로 적절하지 않은지 파악해보시기 바랍니다!
https://www.notion.so/wecode/Westagram-React-Refactoring-Checklist-aea297cf88ed4601b769e4b2c2cfd4e1#089493d6bfca438aa328226e327cff92 |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
... | JavaScript | - isActive 를 state 로 관리할 필요 없이, 여기서 바로 true / false 를 계산하면 될 것 같습니다! |
@@ -1,3 +1,106 @@
-*{
- margin: 0;
-}
\ No newline at end of file
+@import '../../../styles/variable.scss';
+
+.Login {
+ @include flexCenter;
+ flex-direction: column;
+ align-items: center;
+ height: 100vh;
+
+ .loginBox {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+... | Unknown | - css 작업을 하실때 바깥 요소에 특정한 width / height 값을 부여하시는 것 보다, 바깥 요소의 크기는 내용물의 크기 + margin / padding 들의 합으로 자연스럽게 크기가 결정되도록 하시는 게 더 좋습니다.
- 항상 bottom up 방식으로 스타일링 하는 습관을 들여주세요! |
@@ -0,0 +1,26 @@
+import React from 'react';
+import './Aside.scss';
+
+import ProfileWrap from './ProfileWrap/ProfileWrap';
+import StoryBox from './StoryBox/StoryBox';
+import RecommendBox from './RecommendBox/RecommendBox';
+import WestaInfoBox from './WestaInfoBox/WestaInfoBox';
+
+class Aside extends React.Compone... | JavaScript | - Import 순서 수정해주세요! 일반적인 convention을 따르는 이유도 있지만 순서만 잘 지켜주셔도 가독성이 좋아집니다. 아래 순서 참고해주세요.
- React → Library(Package) → Component → 변수 / 이미지 → css 파일(scss 파일)
```suggestion
import React from 'react';
import ProfileWrap from './ProfileWrap/ProfileWrap';
import StoryBox from './StoryBox/StoryBox';
import RecommendBox f... |
@@ -0,0 +1,56 @@
+import React from 'react';
+import './Content.scss';
+
+import Feed from './Feed/Feed';
+import Aside from './Aside/Aside';
+
+class Content extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('http://local... | JavaScript | - `http://localhost:3000` 은 생략 가능합니다. 포트 번호가 달라지면(ex. `localhost:3001`) fetch 함수를 일일이 수정해주어야 하기 때문에 유지보수가 어려워집니다. 아래 코드 참고해서 수정해주세요!
```jsx
const foo = () => {
// fetch("http://localhost:3000/images/1")
fetch("/images/1")
}
```
- fetch함수의 `get method`는 method의 default 값입니다. 따라서 생략이 가능합니다.
```jsx
const foo =... |
@@ -0,0 +1,56 @@
+import React from 'react';
+import './Content.scss';
+
+import Feed from './Feed/Feed';
+import Aside from './Aside/Aside';
+
+class Content extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('http://local... | JavaScript | - mock up 데이터의 키 값은 스네이크 케이스로 사용해주셔도 되지만 (백엔드에서는 보통 스네이크 케이스를 쓰기 때문에) props 의 이름은 카멜 케이스로 통일해 주세요! |
@@ -0,0 +1,31 @@
+package com.antique.dto.review;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ReviewRequestD... | Java | schema 어노테이션을 사용해서 표현하면 더 좋을 것 같아..!! |
@@ -0,0 +1,53 @@
+'use client';
+
+import Button from '@/app/components/common/button/Button';
+import Modal from '@/app/components/common/modal/Modal';
+import IconAlert from '@/app/components/icons/IconAlert';
+
+interface ConfirmModalInterface {
+ title: string;
+ cancelLabel?: string;
+ confirmLabel?: string;
+ ... | Unknown | 공통 컴포넌트 감사합니다!!!! |
@@ -10,6 +10,7 @@ import useModal from '@/app/hooks/useModal';
import DetailMemberModal from '@/app/components/team/DetailMemberModal';
import deleteMember from '@/app/lib/group/deleteMemeber';
import { useMutation, useQueryClient } from '@tanstack/react-query';
+import ConfirmModal from '@/app/components/common/mod... | Unknown | `를 추방하시겠어요?` 라고 명시하면 이름 마지막 글자에 받침이 있는 사람은 문구가 어색하게 보일 수 있을 것 같습니다.
예): 홍지윤를 추방하시겠어요?
그래서 `${member.userName}님을 추방하시겠어요?` 가 더 괜찮을 것 같습니다! |
@@ -10,6 +10,7 @@ import useModal from '@/app/hooks/useModal';
import DetailMemberModal from '@/app/components/team/DetailMemberModal';
import deleteMember from '@/app/lib/group/deleteMemeber';
import { useMutation, useQueryClient } from '@tanstack/react-query';
+import ConfirmModal from '@/app/components/common/mod... | Unknown | 문구 디테일을 놓쳤네요.
반영해서 올리겠습니다. 감사합니다😊 |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | 구조분해할당을 잘 쓰신거 같습니다! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | comment관련 함수를 깔끔하게 잘 정리하신거 같습니다 |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | 커멘트 컴포넌트에 프롭스 전달을 깔끔하게 잘 하신거 같습니다 |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, na... | JavaScript | 삼항연산자 사용을 잘 하신거 같습니다. |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() ... | JavaScript | Lifecycle Method를 잘 사용하신거 같습니다. |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | 저도 적용해보겠습니다!👍 |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, na... | JavaScript | 버튼이 활성화될 때 색상 변경과 비활성화 기능까지 구현하신 점 배워갑니다:) |
@@ -0,0 +1,74 @@
+[
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "alt": "wecode",
+ "img": "/images/youngho/hanRiver.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "content": "한강 다녀감~ ✌️",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "use... | Unknown | 목데이터 사용 너무 좋습니다! :) |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, na... | JavaScript | ```suggestion
<button
onClick={this.handleLogin}
className={condition ? 'buttonActivate' : 'buttonDisabled'}
id="loginButton"
disabled={ condition ? false : true}
>
로그인
</button>
```
해당 조건... |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, na... | JavaScript | 참고로 위의 변수는 render 함수 내에서 선언해주시면 됩니다!! |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding:... | Unknown | ```suggestion
body {
background-color: #fafafa;
}
.container {
text-align: center;
border: 1px solid #e6e6e6;
background-color: white;
width: 600px;
height: 600px;
margin: 50px auto 0 auto;
}
.header {
font-family: 'Lobster', cursive;
font-size: 70px;
font-weight: 1px;
padding:... |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding:... | Unknown | 영호님! 전체적으로 CSS 속성 순서 확인해서 적용해주세요~
- 하나의 요소에 여러가지 속성을 부여하는 경우 중요도, 관련도에 따라서 나름의 convention을 지켜서 작성하는 것이 좋습니다.
- 일반적인 convention 은 아래와 같습니다. 아래와 같이 순서 적용해주세요.
[CSS property 순서]
- Layout Properties (position, float, clear, display)
- Box Model Properties (width, height, margin, padding)
- Visual ... |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() ... | JavaScript | import 순서는 잘 맞춰주셨고, 해당 부분에서는 줄바꿈 없이 진행해주세요~ |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() ... | JavaScript | fetch함수의 `get method는 method의 default` 값입니다. 따라서 `생략이 가능`합니다.
고로 get method 요청시에는 아래와 같이 두번째 인자가 생략 가능합니다.
```jsx
const foo = () => {
fetch(`${cartAPI}/quantity`)
.then((res) => res.json())
``` |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() ... | JavaScript | story 부분이 여러번 반복되고 있네요!
상수 데이터와 map을 사용해서 중복된 부분을 줄여주세요!
```
const STORIES = [
{img: "//", name: "wecorder1"}, {img: "//", name: "wecorder2"}, {img: "//", name: "wecorder3"}
];
STORIES.map();
``` |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ ... | Unknown | 반응형 아주 좋네요!!
브레이크 포인트는 기획마다 달라지지만 보통 태블릿과 데스크탑의 구분점은 1078px이라는 점 알아두세요!
모바일과 태블릿은 768px입니다! |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ ... | Unknown | 같은 스타일의 경우에는 중복하여 주시지 말고 같은 클래스명을 사용하셔도 됩니다! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | import 구분은 너무 좋지만 줄바꿈은 안하셔도 됩니다!!! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | 이렇게 구조분해할당 너무 좋네요!! |
@@ -0,0 +1,74 @@
+[
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "alt": "wecode",
+ "img": "/images/youngho/hanRiver.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "content": "한강 다녀감~ ✌️",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "use... | Unknown | 감사합니다! |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, na... | JavaScript | 반영 완료했습니다! |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding:... | Unknown | 반영 완료했습니다! |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding:... | Unknown | 반영 완료했습니다! |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() ... | JavaScript | 반영 완료했습니다! |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() ... | JavaScript | 반영 완료했습니다! |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ ... | Unknown | 감사합니다! |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ ... | Unknown | 반영 완료했습니다! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | 반영 완료했습니다! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
... | JavaScript | 감사합니다 🌝 |
@@ -0,0 +1,17 @@
+from django.db import models
+
+class User(models.Model):
+ email = models.EmailField(max_length=50, unique=True)
+ password = models.CharField(max_length=100)
+ relation = models.ManyToManyField('self', through='Follow', symmetrical=False)
+
+ class Meta:
+ db_table = "users"
+ ... | Python | 다민님! 잘 작성해주셨는데 `email` 은 겹칠 수 없는 정보이기 때문에 해당하는 옵션을 추가해주시는게 좋습니다! 알아보시고 알맞은 옵션을 추가해주세요~ |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error가 아니라 django의 권장사항. 하지만 패턴 컨벤션에는 위 사항이 맞다.''' | Python | import 하실 때 `*` 사용하지 마시고 명확하게 가져오고 싶은 class 를 적어주세요! |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error가 아니라 django의 권장사항. 하지만 패턴 컨벤션에는 위 사항이 맞다.''' | Python | 이 부분 세션 중 한번 설명 드렸는데, 왜 `/` 관련 warning 이 뜬다고 생각하시나요!? |
@@ -0,0 +1,21 @@
+"""westagram URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/3.1/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: path('', views.hom... | Python | 이 부분은 위코드 url 패턴 컨벤션에 맞지 않습니다. 위에 리뷰드린 내용 중 `/` 관련 질문 남겨드렸으니 확인해주세요. |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | 깔끔하네요~! 💯 |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | `json.loads()` 도 핸들해주셔야하는 exception 이 발생할 수 있습니다. 확인해보시고 추가해주세요! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | 다민님이 작성하신 코드 로직을 순서대로 정리해보겠습니다.
1. `client` 에서 들어온 `email`, `password` 값을 이용하여 일치하는 user 를 filter 하는 쿼리를 날려 user 변수에 저장해준다.
2. `email` 로 filter 쿼리를 날려 존재하는 user 인지 확인한다.
3. `password` 로 filter 쿼리를 날려 존재하는 user 인지 확인한다.
4. client 에서 들어온 `email`, `password` 가 유효한 포맷인지 검사하여 유효하다면 CREATE 를 진행한다.
이렇게 말로 정리해보니 흐름이 좀 어... |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | 여기서 잠깐 질문!
`KeyError` 어떤 에러이며, 언제 발생할까요? |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | SignupView 와 비슷한 로직 흐름이네요. 위쪽 남겨드린 질문 먼저 확인해주세요! |
@@ -0,0 +1,17 @@
+from django.db import models
+
+class User(models.Model):
+ email = models.EmailField(max_length=50, unique=True)
+ password = models.CharField(max_length=100)
+ relation = models.ManyToManyField('self', through='Follow', symmetrical=False)
+
+ class Meta:
+ db_table = "users"
+ ... | Python | `from django.db import models
class User(models.Model):
email = models.EmailField(max_length=50, unique=True)` 로 해결했습니다. |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error가 아니라 django의 권장사항. 하지만 패턴 컨벤션에는 위 사항이 맞다.''' | Python | `from django.urls import path
from .views import SignupView, LoginView` 로 필요한 뷰 클래스 가져오는 것으로 수정하였습니다. |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error가 아니라 django의 권장사항. 하지만 패턴 컨벤션에는 위 사항이 맞다.''' | Python | Error가 아니라 django의 권장사항이어서 그렇습니다. 하지만 패턴 컨벤션에는 고쳐서 쓰는 것이 맞기 때문에 고쳤습니다. |
@@ -0,0 +1,21 @@
+"""westagram URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/3.1/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: path('', views.hom... | Python | 수정하였습니다. |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | `class SignupView(View):
def post(self, request):
try:
data = json.loads(request.body)
user = User.objects.filter(email=data['email'],password=data['password'])`
아래 로그인뷰도 똑같은 형태로 바꿨습니다.
이유 : 사용자에게 형식을 받을 때 꼭 내가 원하는 형태로 json이 오지 않을 수 있기에 Key-error 상황을 줘야 하기 때문. |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | 이거 택향님하고 이야기하다가 안 것인데, 키 에러란 딕셔너리 형태에서 자주 발생하며 딕셔너리 내부에 존재하지 않는 키를 사용해서 값을 내려고 할 때 나는 에러입니다. 이번 예시로는 만일 데이터가 email=~~~ password=~~~ 로 오는 것이 아니라 emailadkfj=~~~ apsdkfjsa=~~~처럼 키 내용이 잘못 와버리는 경우 예외 처리로 키 에러를 내기 위해 하는 것으로 의도하고 했습니다! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | 확인했습니다 |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body... | Python | 먼저 두 클래스 모두 공통적으로 user라는 변수가 불필요해서 지웠습니다.
- 이유 : 이미 User.~를 통해 쿼리를 날려 데이터에서 필요한 자료를 가져올 수 있다. 불필요한 변수였다.
- comment :
1. client에서 들어온 값 중 이메일 필터 쿼리를 날려 존재하는 이메일일 경우인지 확인.
2. (마찬가지로) 비밀번호 필터 쿼리를 날려 존재하는 비밀번호인지 확인.
3. 이메일과 비밀번호가 유효한 포맷인지 검사하여 유효하면 값 만들기 진행.
- 아직 쿼리를 날린다는 개념이 확실히 서지 않아 표현이 맞는건지는 모르겠습니다. 문법적인 점은 검토해... |
@@ -0,0 +1,17 @@
+from django.db import models
+
+class User(models.Model):
+ email = models.EmailField(max_length=50, unique=True)
+ password = models.CharField(max_length=100)
+ relation = models.ManyToManyField('self', through='Follow', symmetrical=False)
+
+ class Meta:
+ db_table = "users"
+ ... | Python | `unique=True` 굳입니다!! |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.