Search in sources :

Example 86 with User

use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-server-android-client by youngmonkeys.

the class EzyAppExitHandler method handle.

@Override
public void handle(EzyArray data) {
    EzyZone zone = client.getZone();
    EzyAppManager appManager = zone.getAppManager();
    int appId = data.get(0, int.class);
    int reasonId = data.get(1, int.class);
    EzyApp app = appManager.removeApp(appId);
    EzyLogger.info("user exit app: " + app + " reason: " + reasonId);
    postHandle(app, data);
}
Also used : EzyZone(com.tvd12.ezyfoxserver.client.entity.EzyZone) EzyApp(com.tvd12.ezyfoxserver.client.entity.EzyApp) EzyAppManager(com.tvd12.ezyfoxserver.client.manager.EzyAppManager)

Example 87 with User

use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-examples by tvd12.

the class GoogleService method getUserInfoByAccessToken.

@Override
public Userinfo getUserInfoByAccessToken(String accessTokenStr) {
    Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessTokenStr);
    Oauth2 oauth2 = new Oauth2.Builder(new NetHttpTransport(), new GsonFactory(), credential).setApplicationName("Oauth2").build();
    try {
        return oauth2.userinfo().get().execute();
    } catch (Exception e) {
        logger.info("get google user information by access token error", e);
        return null;
    }
}
Also used : Credential(com.google.api.client.auth.oauth2.Credential) GsonFactory(com.google.api.client.json.gson.GsonFactory) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) Oauth2(com.google.api.services.oauth2.Oauth2) EzyMapBuilder(com.tvd12.ezyfox.util.EzyMapBuilder)

Example 88 with User

use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-examples by tvd12.

the class RegisterController method registerPost.

@DoPost("/register")
public Redirect registerPost(@RequestBody RegisterRequest request) {
    final User user = new User(request.getUsername(), request.getPassword(), request.getBirthOfDate(), LocalDate.now(), LocalDateTime.now());
    userService.addUser(user);
    return Redirect.to("/user/" + request.getUsername());
}
Also used : User(org.youngmonkeys.example.ezyhttp.thymeleaf.entity.User) DoPost(com.tvd12.ezyhttp.server.core.annotation.DoPost)

Example 89 with User

use of com.tvd12.example.lucky_wheel.entity.User in project ezyfox-examples by tvd12.

the class UserController method userSavePost.

@DoPost("/user/save")
public Object userSavePost(@UserId long userId, @RequestBody UpdateUserRequest request) {
    User user = userService.getUserById(userId);
    if (user == null) {
        throw new UserNotFoundException("user with id: " + userId + " not found");
    }
    user.setEmail(request.getEmail());
    user.setFullName(request.getFirstName() + " " + request.getLastName());
    user.setFirstName(request.getFirstName());
    user.setLastName(request.getLastName());
    user.setStatus(UserStatus.UPDATED);
    user.setPassword(EzySHA256.cryptUtfToLowercase(request.getPassword()));
    userService.saveUser(user);
    return Redirect.builder().uri("/home").build();
}
Also used : UserNotFoundException(org.youngmonkeys.example.ezyhttp.login.exception.UserNotFoundException) User(org.youngmonkeys.example.ezyhttp.login.entity.User) DoPost(com.tvd12.ezyhttp.server.core.annotation.DoPost)

Aggregations

Test (org.testng.annotations.Test)42 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)33 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)28 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)25 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)20 EzyArray (com.tvd12.ezyfox.entity.EzyArray)16 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)16 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)15 BaseTest (com.tvd12.test.base.BaseTest)14 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)13 BaseCoreTest (com.tvd12.ezyfoxserver.testing.BaseCoreTest)12 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)10 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)10 EzySimpleAppSetting (com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting)8 GreetResponse (com.tvd12.ezyfoxserver.support.test.data.GreetResponse)8 EzyAppUserManager (com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager)8 EzyDoHandle (com.tvd12.ezyfox.core.annotation.EzyDoHandle)7 EzySimpleApplication (com.tvd12.ezyfoxserver.EzySimpleApplication)7 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)7 EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)7