Uses only token now
Need to implement timeout later
This commit is contained in:
parent
77c5ffbb15
commit
0681105778
@ -103,11 +103,10 @@ class ApplicationController extends DefaultWindowController {
|
||||
final case class ApplicationName(name: String)
|
||||
final case class UserCredentials(
|
||||
username: String,
|
||||
password: String,
|
||||
token: String
|
||||
)
|
||||
object UserCredentials {
|
||||
def empty = UserCredentials("empty", "empty", "empty")
|
||||
def empty = UserCredentials("empty", "empty")
|
||||
}
|
||||
|
||||
@ApplicationScoped
|
||||
|
@ -78,7 +78,7 @@ class LoginController @Inject() (
|
||||
case Some(token) =>
|
||||
async {
|
||||
val credentials =
|
||||
UserCredentials(inputUserName, inputPassword, token)
|
||||
UserCredentials(inputUserName, token)
|
||||
appDataHandler.updateCredentials(credentials)
|
||||
updateErrorLabel("")
|
||||
applicationController.showChatPane()
|
||||
|
@ -32,10 +32,13 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
||||
DefaultFormats ++ JavaTimeSerializers.all
|
||||
private val domain = "http://localhost:8080"
|
||||
private lazy val baseUrl = uri"$domain/api/chat"
|
||||
private lazy val authBasicRequest = (credentials: UserCredentials) =>
|
||||
basicRequest.auth
|
||||
.basic(credentials.username, credentials.password)
|
||||
.header("X-AUTH-TOKEN", credentials.token)
|
||||
// private lazy val authBasicRequest = (credentials: UserCredentials) =>
|
||||
// basicRequest.auth
|
||||
// .basic(credentials.username, credentials.password)
|
||||
// .header("X-AUTH-TOKEN", credentials.token)
|
||||
private lazy val tokenBasicRequest = (token: String) => {
|
||||
basicRequest.header("X-AUTH-TOKEN", token)
|
||||
}
|
||||
|
||||
def func1() = async {
|
||||
val willBeResponse = func2()
|
||||
@ -59,7 +62,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
||||
// )
|
||||
// )
|
||||
await {
|
||||
authBasicRequest(credentials)
|
||||
// authBasicRequest(credentials)
|
||||
tokenBasicRequest(credentials.token)
|
||||
.get(uri"http://localhost:8080/api/chat/get/users")
|
||||
.response(asJson[List[String]])
|
||||
.send()
|
||||
@ -69,7 +73,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
||||
def getMessages(credentials: UserCredentials) = async {
|
||||
// logger.debug(s"${appDataHandler.appData}")
|
||||
await {
|
||||
authBasicRequest(credentials)
|
||||
// authBasicRequest(credentials)
|
||||
tokenBasicRequest(credentials.token)
|
||||
.get(uri"http://localhost:8080/api/chat/get/users")
|
||||
.response(asJson[List[String]])
|
||||
.send()
|
||||
@ -77,7 +82,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
||||
}
|
||||
|
||||
def getActiveUsers(credentials: UserCredentials) =
|
||||
authBasicRequest(credentials)
|
||||
// authBasicRequest(credentials)
|
||||
tokenBasicRequest(credentials.token)
|
||||
.get(uri"http://localhost:8080/api/chat/get/active-users")
|
||||
.response(asJson[List[ActiveUser]])
|
||||
.send()
|
||||
|
Loading…
Reference in New Issue
Block a user