Skip to content

Commit

Permalink
Migrate password
Browse files Browse the repository at this point in the history
  • Loading branch information
making committed Aug 17, 2023
1 parent d75d79a commit 6804197
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import org.springframework.jdbc.core.DataClassRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsPasswordService;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class AccountUserDetailsService implements UserDetailsService {
public class AccountUserDetailsService implements UserDetailsService, UserDetailsPasswordService {

private final JdbcTemplate jdbcTemplate;

Expand All @@ -30,4 +31,10 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx
}
}

@Override
public UserDetails updatePassword(UserDetails user, String newPassword) {
this.jdbcTemplate.update("UPDATE account SET password = ? WHERE username = ?", newPassword, user.getUsername());
return new AccountUserDetails(new Account(user.getUsername(), newPassword));
}

}

0 comments on commit 6804197

Please sign in to comment.