-
Notifications
You must be signed in to change notification settings - Fork 1
Get all info user #93 #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -11,3 +11,15 @@ class ReceiptNotFoundException(val fn: String, val fd: String, val fp: String) | |||
@ResponseStatus(code = HttpStatus.FORBIDDEN) | |||
class AuthorizationFailedException(login: String, cause: Throwable? = null) | |||
: FnsException("Login with phone $login failed", cause) | |||
|
|||
@ResponseStatus(code = HttpStatus.CONFLICT) | |||
class UserWasExistException(userName: String, cause: Throwable? = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserAlreadyExistsException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил
throw UserWasExistException(name, e) | ||
} catch (c: HttpClientErrorException.BadRequest) { | ||
throw IncorrectEmailException(email, c) | ||
} catch (d: HttpServerErrorException.InternalServerError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InternalServerError возникает буквально в любой непонятной ситуации.
Не всякий IE (InternalError) - это неправильный номер.
Есть варианты как понять что дело именно в номере?
Может, там приходит текст в ответ с описанием
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
переделал
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/excepion/FnsException.kt
Show resolved
Hide resolved
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Outdated
Show resolved
Hide resolved
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
|
||
@Throws(IOException::class) | ||
override fun handleError(httpResponse: ClientHttpResponse) { | ||
when { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Внутри when какой то бесполезный код
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поправил
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
} | ||
|
||
fun login(login: String, password: String) { | ||
fun login(phone: String, password: String): ResponseEntity<UserResponseLoginFnsDto>? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут нужно возвращать просто UserResponseLoginDto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделал
|
||
@Throws(IOException::class) | ||
override fun handleError(httpResponse: ClientHttpResponse) { | ||
if (httpResponse.statusCode == HttpStatus.NO_CONTENT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А если hasError всегда возвращает false, то разве он сюда вообще зайдет когда нибудь?
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
package space.shefer.receipt.fnssdk.dto | ||
|
||
|
||
class UserResponseLoginFnsDto { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Переименуй FnsLoginResponse
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/excepion/FnsException.kt
Outdated
Show resolved
Hide resolved
} else if (responseEntity.statusCode == HttpStatus.INTERNAL_SERVER_ERROR) { | ||
throw IncorrectPhoneException(phone) | ||
} | ||
} catch (e: Exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем ловить Exception? какие ошибки мы тут ожидаем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ловлю UnsupportedOperationException, подозреваю что это дублирование кода, так как все ошибки я уже отработал в ResponseErrorHandleFNS
if (authHeader != null) { | ||
return fnsUserService.getUserByToken(authHeader.substring(authHeader.indexOf(" ") + 1)); | ||
} | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не null а 404 нужно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
или 403
FnsLoginResponse responseEntity = fnsReceiptWebClient.login(userLoginDto.getPhone(), userLoginDto.getPassword()); | ||
if (responseEntity != null) { | ||
UserProfile userProfile = userProfileRepository.getByPhone(userLoginDto.getPhone()); | ||
if (userProfile != null && userProfile.getUpdatedAt() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а зачем проверка updatedAt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
изменил. Она тут не нужна, забыл убрать, логику переделал.
@RequestMapping(value = "/users/me", method = RequestMethod.GET) | ||
public UserSignUpDto getInfoByToken(@Nullable @RequestHeader("Authorization") String authHeader) { | ||
if (authHeader != null) { | ||
return fnsUserService.getUserByToken(authHeader.substring(authHeader.indexOf(" ") + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authHeader.substring(authHeader.indexOf(" ") + 1)
вынести в новый метод getTokenFromAuthHeader(String header)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделал
String::class.java | ||
) | ||
FnsLoginResponse::class.java | ||
).body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поставь тут !! и в методе возвращаемый тип сделай без вопросика
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Расскажи подробнее, что это и как. Я даже не знаю как это загуглить)
URI("$HOST/v1/mobile/users/signup"), | ||
HttpMethod.POST, | ||
HttpEntity("""{"email":"$email","name":"$name","phone":"$phone"}""", headers), | ||
String::class.java | ||
) | ||
if (responseEntity.statusCode == HttpStatus.CONFLICT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сначала нужно проверить что если 2XX, то сразу return. иначе начинать перебиравть ифами ошибки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделал
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
|
||
@Throws(IOException::class) | ||
override fun handleError(httpResponse: ClientHttpResponse) { | ||
if (httpResponse.statusCode == HttpStatus.NO_CONTENT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
этот код обрабатывает ошибки
а еще код в тоже обрабатываает эти же самые ошибки
нужно чтобы обрабатывалось все в FnsReceiptWebClient::signUp
, а тут ничего не обрабатывалось
перенеси логику отсюда туда
hasError должен всегда возвращать false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенес
No description provided.