質問編集履歴

1

ログイン部分のソースも追加しました

2019/03/01 13:27

投稿

takahiro00
takahiro00

スコア84

test CHANGED
File without changes
test CHANGED
@@ -94,6 +94,72 @@
94
94
 
95
95
  ```
96
96
 
97
+ ログイン部分?は以下です
98
+
99
+ ```java
100
+
101
+ package com.kproject01.impl;
102
+
103
+
104
+
105
+ import org.springframework.beans.factory.annotation.Autowired;
106
+
107
+ import org.springframework.security.core.userdetails.UserDetails;
108
+
109
+ import org.springframework.security.core.userdetails.UserDetailsService;
110
+
111
+ import org.springframework.security.core.userdetails.UsernameNotFoundException;
112
+
113
+ import org.springframework.stereotype.Service;
114
+
115
+
116
+
117
+ import com.kproject01.data.LoginUserData;
118
+
119
+ import com.kproject01.entity.MUser;
120
+
121
+ import com.kproject01.repository.UserRepository;
122
+
123
+
124
+
125
+ @Service
126
+
127
+ public class LoginUserDetailsServiceImpl implements UserDetailsService {
128
+
129
+
130
+
131
+ @Autowired
132
+
133
+ UserRepository userRepository;
134
+
135
+
136
+
137
+ @Override
138
+
139
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
140
+
141
+ MUser user = userRepository.findByUsername(username);
142
+
143
+
144
+
145
+ if (user == null) {
146
+
147
+ throw new UsernameNotFoundException("not found");
148
+
149
+ }
150
+
151
+ return new LoginUserData(user);
152
+
153
+ }
154
+
155
+
156
+
157
+ }
158
+
159
+
160
+
161
+ ```
162
+
97
163
 
98
164
 
99
165