Merge pull request 'add 'rst' to Login component' (#20) from feature/18-add-rst-login into dev
Reviewed-on: #20 close #18
This commit is contained in:
commit
4604f86429
@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import isURL from "validator/lib/isURL";
|
import isURL from "validator/lib/isURL";
|
||||||
import isUUID from "validator/lib/isUUID";
|
import isUUID from "validator/lib/isUUID";
|
||||||
import { apikey, lang, stationinfo, api_endpoint } from "./store.js";
|
import { apikey, lang, stationinfo, api_endpoint, page } from "./store.js";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import background from "./kaya_kids_background.jpg";
|
import background from "./kaya_kids_background.jpg";
|
||||||
import { _, locale } from "svelte-i18n";
|
import { _, locale } from "svelte-i18n";
|
||||||
@ -10,9 +10,10 @@
|
|||||||
$: error = false;
|
$: error = false;
|
||||||
$: errormessage = "";
|
$: errormessage = "";
|
||||||
$: isTokenValid =
|
$: isTokenValid =
|
||||||
token?.length === 44 &&
|
token === "rst" ||
|
||||||
|
(token?.length === 44 &&
|
||||||
token.split(".")[0].length === 7 &&
|
token.split(".")[0].length === 7 &&
|
||||||
isUUID(token.split(".")[1]);
|
isUUID(token.split(".")[1]));
|
||||||
$: isEndpointValid = isURL(api_endpoint_input);
|
$: isEndpointValid = isURL(api_endpoint_input);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -67,6 +68,13 @@
|
|||||||
class="flex flex-col pt-3 md:pt-8"
|
class="flex flex-col pt-3 md:pt-8"
|
||||||
onsubmit="event.preventDefault();"
|
onsubmit="event.preventDefault();"
|
||||||
on:submit={() => {
|
on:submit={() => {
|
||||||
|
if (token === "rst") {
|
||||||
|
apikey.set("");
|
||||||
|
api_endpoint.set("");
|
||||||
|
page.set("");
|
||||||
|
token = "";
|
||||||
|
api_endpoint_input = "";
|
||||||
|
} else {
|
||||||
axios
|
axios
|
||||||
.request({
|
.request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@ -83,6 +91,7 @@
|
|||||||
error = true;
|
error = true;
|
||||||
errormessage = e.response.data.short;
|
errormessage = e.response.data.short;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="flex flex-col pt-4">
|
<div class="flex flex-col pt-4">
|
||||||
@ -118,10 +127,18 @@
|
|||||||
class="flex flex-col pt-3 md:pt-8"
|
class="flex flex-col pt-3 md:pt-8"
|
||||||
onsubmit="event.preventDefault();"
|
onsubmit="event.preventDefault();"
|
||||||
on:submit={() => {
|
on:submit={() => {
|
||||||
|
if (api_endpoint_input === "rst") {
|
||||||
|
apikey.set("");
|
||||||
|
api_endpoint.set("");
|
||||||
|
page.set("");
|
||||||
|
token = "";
|
||||||
|
api_endpoint_input = "";
|
||||||
|
} else {
|
||||||
if (api_endpoint_input.substr(-1) !== "/") {
|
if (api_endpoint_input.substr(-1) !== "/") {
|
||||||
api_endpoint_input = api_endpoint_input + "/";
|
api_endpoint_input = api_endpoint_input + "/";
|
||||||
}
|
}
|
||||||
api_endpoint.set(api_endpoint_input);
|
api_endpoint.set(api_endpoint_input);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="flex flex-col pt-4">
|
<div class="flex flex-col pt-4">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user