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

Merge branch '会員登録API' into 'master'

会員登録API途中

See merge request !11
parents a8bc7544 d6112fed
......@@ -21,9 +21,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.mvcMatchers("/limited/login").permitAll() //ログイン前でもアクセス可能なURLの指定
.mvcMatchers("/limited/login","/limited/signUp").permitAll() //ログイン前でもアクセス可能なURLの指定
.mvcMatchers("/limited/admin/**").hasRole("ADMIN")//ADMIN権限のユーザーのみアクセスできるURLの指定
.anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定
.anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定s
.and()
.formLogin()
.loginProcessingUrl("/login") //ログイン処理でpostするURL
......
......@@ -4,6 +4,7 @@ import java.sql.Date;
import java.time.LocalDate;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -20,11 +21,12 @@ public class EcsiteRestController {
@PostMapping("signUp")
public User createUser(@RequestBody User user) {
user.setRoles("user");
user.setRoles("USER");
LocalDate localDate = LocalDate.now();
Date nowDate = Date.valueOf(localDate);
user.setCreatedAt(nowDate);
user.setUpdatedAt(nowDate);
user.setPassword(new Pbkdf2PasswordEncoder().encode(user.getPassword()));
loginUserDetailsService.create(user);
return user;
}
......
......@@ -7,8 +7,6 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
......@@ -26,7 +24,7 @@ public class User {
private String address;
private String phoneNumber;
private String email;
@JsonIgnore
// @JsonIgnore
private String password;
private String roles;
private Date createdAt;
......
//モーダル表示
$(function(){
$('.js-modal-open').on('click',function(){
$('.js-modal').fadeIn();
......@@ -7,4 +8,34 @@ $(function(){
$('.js-modal').fadeOut();
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 @@
<head>
<meta charset="utf-8"/>
<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="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="stylesheet" href="css/style.css" th:href="@{/css/style.css}"/>
<title>Mart - HTML5 Resoponsive onepage e-commerce template </title>
<!--[if lt IE 9]>
<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