Commit d6112fed authored by shoei.kanno's avatar shoei.kanno

会員登録API途中

parent 4e78b81d
...@@ -21,9 +21,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{ ...@@ -21,9 +21,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http http
.authorizeRequests() .authorizeRequests()
.mvcMatchers("/limited/login").permitAll() //ログイン前でもアクセス可能なURLの指定 .mvcMatchers("/limited/login","/limited/signUp").permitAll() //ログイン前でもアクセス可能なURLの指定
.mvcMatchers("/limited/admin/**").hasRole("ADMIN")//ADMIN権限のユーザーのみアクセスできるURLの指定 .mvcMatchers("/limited/admin/**").hasRole("ADMIN")//ADMIN権限のユーザーのみアクセスできるURLの指定
.anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定 .anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定s
.and() .and()
.formLogin() .formLogin()
.loginProcessingUrl("/login") //ログイン処理でpostするURL .loginProcessingUrl("/login") //ログイン処理でpostするURL
......
...@@ -4,6 +4,7 @@ import java.sql.Date; ...@@ -4,6 +4,7 @@ import java.sql.Date;
import java.time.LocalDate; import java.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -20,11 +21,12 @@ public class EcsiteRestController { ...@@ -20,11 +21,12 @@ public class EcsiteRestController {
@PostMapping("signUp") @PostMapping("signUp")
public User createUser(@RequestBody User user) { public User createUser(@RequestBody User user) {
user.setRoles("user"); user.setRoles("USER");
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();
Date nowDate = Date.valueOf(localDate); Date nowDate = Date.valueOf(localDate);
user.setCreatedAt(nowDate); user.setCreatedAt(nowDate);
user.setUpdatedAt(nowDate); user.setUpdatedAt(nowDate);
user.setPassword(new Pbkdf2PasswordEncoder().encode(user.getPassword()));
loginUserDetailsService.create(user); loginUserDetailsService.create(user);
return user; return user;
} }
......
...@@ -7,8 +7,6 @@ import javax.persistence.GeneratedValue; ...@@ -7,8 +7,6 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -26,7 +24,7 @@ public class User { ...@@ -26,7 +24,7 @@ public class User {
private String address; private String address;
private String phoneNumber; private String phoneNumber;
private String email; private String email;
@JsonIgnore // @JsonIgnore
private String password; private String password;
private String roles; private String roles;
private Date createdAt; private Date createdAt;
......
//モーダル表示
$(function(){ $(function(){
$('.js-modal-open').on('click',function(){ $('.js-modal-open').on('click',function(){
$('.js-modal').fadeIn(); $('.js-modal').fadeIn();
...@@ -7,4 +8,34 @@ $(function(){ ...@@ -7,4 +8,34 @@ $(function(){
$('.js-modal').fadeOut(); $('.js-modal').fadeOut();
return false; return false;
}); });
});
//モーダルフォーム送信
$('#ok-btn').on('click', function(){
let token = $("meta[name='_csrf']").attr("content");
let header = $("meta[name='_csrf_header']").attr("content");
$(document).ajaxSend(function(e, xhr, options) {
xhr.setRequestHeader(header, token);
});
let data = {
name: $('#name').val(),
postalCode: $('#postal-code').val(),
address: $('#address').val(),
phoneNumber: $('#phone-number').val(),
email: $('#email').val(),
password: $('#password').val()
};
$.ajax({
type: "POST",
url: "/limited/signUp",
contentType: 'application/json',
dataType: "json",
data: JSON.stringify(data)
}).done(function(response, textStatus, jqXHR ) {
// Todo success process
}).fail(function(jqXHR, textStatus, errorThrown) {
alert("Failed.");
});
}); });
\ No newline at end of file
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>Mart - HTML5 Resoponsive onepage e-commerce template </title>
<meta name="description" content=""/> <meta name="description" content=""/>
<meta name="viewport" content="width=device-width, initial-scale=1"/> <meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- csrf -->
<meta name="_csrf" th:content="${_csrf.token}"/>
<meta name="_csrf_header" th:content="${_csrf.headerName}"/>
<link rel="icon" href="images/favicon.png" th:href="@{/images/favicon.png}"/> <link rel="icon" href="images/favicon.png" th:href="@{/images/favicon.png}"/>
<link rel="stylesheet" href="css/style.css" th:href="@{/css/style.css}"/> <link rel="stylesheet" href="css/style.css" th:href="@{/css/style.css}"/>
<title>Mart - HTML5 Resoponsive onepage e-commerce template </title>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment