Search in sources :

Example 1 with User

use of com.springboot.cli.domain.User in project springboot-cli by liangqiding.

the class UserRealm method doGetAuthenticationInfo.

/**
 * 认证
 * 此处实现我们的登录逻辑,如账号密码验证
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
    // 获取到token
    UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
    // 从token中获取到用户名和密码
    String username = token.getUsername();
    String password = String.valueOf(token.getPassword());
    // 为了方便,这里模拟获取用户
    User user = this.getUser();
    if (!user.getUsername().equals(username)) {
        throw new UnknownAccountException("用户不存在");
    } else if (!user.getPassword().equals(password)) {
        throw new IncorrectCredentialsException("密码错误");
    }
    // 校验完成后,此处我们把用户信息返回,便于后面我们通过Subject获取用户的登录信息
    return new SimpleAuthenticationInfo(user, password, getName());
}
Also used : User(com.springboot.cli.domain.User)

Example 2 with User

use of com.springboot.cli.domain.User in project springboot-cli by liangqiding.

the class UserServiceImpl method updUser.

@Override
public boolean updUser(User user) {
    StrUtil.isNotBlank(user.getPassword());
    UpdateWrapper<User> set = new UpdateWrapper<User>().eq("user_id", user.getUserId()).set(StrUtil.isNotBlank(user.getPassword()), "password", user.getPassword()).set(StrUtil.isNotBlank(user.getUsername()), "username", user.getUsername()).set("updated_date", new Date());
    return this.update(set);
}
Also used : User(com.springboot.cli.domain.User) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) Date(java.util.Date)

Example 3 with User

use of com.springboot.cli.domain.User in project springboot-cli by liangqiding.

the class MybatisGenerationApplicationTests method listUser.

@Test
void listUser() {
    List<User> users = userService.listUser(new User());
    System.out.println(JSON.toJSONString(users));
}
Also used : User(com.springboot.cli.domain.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

User (com.springboot.cli.domain.User)3 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)1 Date (java.util.Date)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1