package com.example.service;

import org.springframework.security.core.authority.AuthorityUtils;

import com.example.domain.User;

//ユーザーの認証・認可にかかわるクラス
public class LoginUser extends org.springframework.security.core.userdetails.User{
	
	private static final long serialVersionUID = 1L;
	private User user;
	
	public LoginUser(User user){
		super(user.getEmail(), user.getPassword(), AuthorityUtils.createAuthorityList(user.getRoles()));
		this.user = user;
	}
	
	/*public User getUser() {
		return user;
	}*/
	
	
	/*static Set<GrantedAuthority> convertGrantedAuthorities(String roles){
		if(roles == null || roles.isEmpty()){
			return Collections.emptySet();
		}
		Set<GrantedAuthority> authorities = Stream.of(roles.split(","))
				.map(SimpleGrantedAuthority::new)
				.collect(Collectors.toSet());
		return authorities;
	}*/
}
