Skip to content

Commit

Permalink
Get proxy header and fix scope descriptions missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 authored and Brutus5000 committed Aug 18, 2023
1 parent 3299886 commit 026deec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ScopeItem : HorizontalLayout() {
translation
}
val descriptionTranslation = getTranslation("oauth2.scope.$scope.description")
if (!descriptionTranslation.matches(Regex("!\\{.*}!"))) {
if (!descriptionTranslation.isNullOrBlank() && !descriptionTranslation.matches(Regex("!\\{.*}!"))) {
infoTooltip.setTooltip(descriptionTranslation)
} else {
infoTooltip.setTooltip(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.vaadin.flow.component.textfield.TextField
import com.vaadin.flow.router.BeforeEnterEvent
import com.vaadin.flow.router.BeforeEnterObserver
import com.vaadin.flow.router.Route
import com.vaadin.flow.server.VaadinSession
import com.vaadin.flow.server.VaadinRequest
import java.time.format.DateTimeFormatter

@Route("/oauth2/login", layout = OAuthCardLayout::class)
Expand Down Expand Up @@ -94,7 +94,9 @@ class LoginView(private val hydraService: HydraService, private val fafPropertie
}

fun login() {
val ipAddress = IpAddress(VaadinSession.getCurrent().browser.address)
val currentRequest = VaadinRequest.getCurrent()
val realIp = currentRequest.getHeader(fafProperties.realIpHeader()) ?: currentRequest.remoteAddr
val ipAddress = IpAddress(realIp)
when (val loginResponse = hydraService.login(challenge, usernameOrEmail.value, password.value, ipAddress)) {
is LoginResponse.FailedLogin -> displayErrorMessage(loginResponse.recoverableLoginFailure)
is LoginResponse.RejectedLogin -> displayRejectedMessage(loginResponse.unrecoverableLoginFailure)
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,21 @@ oauth2.scope.write_account_data.description=Such as change password or email
oauth2.scope.edit_clan_data=Edit clan data
oauth2.scope.edit_clan_data.description=Such as renaming or inviting players
oauth2.scope.vote=Participate in FAF votes
oauth2.scope.vote.description=
oauth2.scope.upload_map=Upload maps
oauth2.scope.upload_map.description=
oauth2.scope.upload_mod=Upload mods
oauth2.scope.upload_mod.description=
oauth2.scope.manage_vault=Manage vault
oauth2.scope.manage_vault.description=Such as hide and unrank maps or mods
oauth2.scope.administrative_actions=Perform administrative actions
oauth2.scope.administrative_actions.description=Such as kick, ban, broadcast message, ...
oauth2.scope.read_sensible_userdata=View sensible user data
oauth2.scope.read_sensible_userdata.description=Such as email, steam id, bans, ...
oauth2.scope.upload_avatar=Upload avatars
oauth2.scope.upload_avatar.description=
oauth2.scope.lobby=Play in the game lobby
oauth2.scope.lobby.description=
ban.title=You are banned from FAForever
ban.expiration=Ban expires:
ban.permanent=Never
Expand Down

0 comments on commit 026deec

Please sign in to comment.