use of com.willshex.blogwt.shared.api.user.call.LoginResponse in project blogwt by billy1380.
the class SessionController method createAsyncResponse.
/**
* @param input
* @return
*/
private AsyncCallback<LoginResponse> createAsyncResponse(final LoginRequest input) {
return new AsyncCallback<LoginResponse>() {
@Override
public void onSuccess(LoginResponse result) {
if (result.status == StatusType.StatusTypeSuccess && result.session != null) {
session = result.session;
Cookies.setCookie(COOKIE_KEY_ID, session.id.toString(), DateTimeHelper.millisFromNow(DateTimeHelper.MILLIS_PER_DAY * 365L * 20L));
if (user() != null && user().lastLoggedIn == null) {
user().lastLoggedIn = new Date();
}
}
DefaultEventBus.get().fireEventFromSource(new LoginSuccess(input, result), SessionController.this);
}
@Override
public void onFailure(Throwable caught) {
DefaultEventBus.get().fireEventFromSource(new LoginFailure(input, caught), SessionController.this);
}
};
}
use of com.willshex.blogwt.shared.api.user.call.LoginResponse in project blogwt by billy1380.
the class UserService method login.
public Request login(LoginRequest input, AsyncSuccess<LoginRequest, LoginResponse> onSuccess, AsyncFailure<LoginRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodLogin, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
LoginResponse outputParameter = new LoginResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodLogin, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodLogin, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodLogin, input, exception);
}
});
onCallStart(UserService.this, UserMethodLogin, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodLogin, input, exception);
}
return handle;
}
Aggregations