Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
Ecsite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shoei.kanno
Ecsite
Commits
d6112fed
Commit
d6112fed
authored
Oct 16, 2020
by
shoei.kanno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会員登録API途中
parent
4e78b81d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
7 deletions
+42
-7
SecurityConfig.java
src/main/java/com/example/SecurityConfig.java
+2
-2
EcsiteRestController.java
src/main/java/com/example/api/EcsiteRestController.java
+3
-1
User.java
src/main/java/com/example/domain/User.java
+1
-3
login.js
src/main/resources/static/js/login.js
+32
-0
login.html
src/main/resources/templates/login.html
+4
-1
No files found.
src/main/java/com/example/SecurityConfig.java
View file @
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
...
...
src/main/java/com/example/api/EcsiteRestController.java
View file @
d6112fed
...
...
@@ -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
;
}
...
...
src/main/java/com/example/domain/User.java
View file @
d6112fed
...
...
@@ -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
;
...
...
src/main/resources/static/js/login.js
View file @
d6112fed
//モーダル表示
$
(
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
src/main/resources/templates/login.html
View file @
d6112fed
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment