Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
imageboard-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Trirst
imageboard-web
Commits
01a78b0b
Commit
01a78b0b
authored
Jun 24, 2021
by
Trirst
Browse files
Options
Downloads
Patches
Plain Diff
Remove authentication page. Make authentication component.
parent
0d60b997
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/UserAuthentication.vue
+47
-0
47 additions, 0 deletions
src/components/UserAuthentication.vue
src/router/index.js
+0
-6
0 additions, 6 deletions
src/router/index.js
src/views/Home.vue
+5
-2
5 additions, 2 deletions
src/views/Home.vue
with
52 additions
and
8 deletions
src/
views/User
.vue
→
src/
components/UserAuthentication
.vue
+
47
−
0
View file @
01a78b0b
<
template
>
<section
id=
"login-section"
>
<div
id=
"login-container"
>
<div>
<button
v-show=
"!loggingIn"
@
click=
"loggingIn = true"
>
Authenticate
</button>
<input
v-model=
"snowflake"
placeholder=
"ID"
name=
"snowflake"
v-show=
"loggingIn"
type=
"text"
/>
</div>
<div>
<input
v-model=
"secret"
placeholder=
"Secret token"
name=
"secret-token"
type=
"text"
v-model=
"secret"
/>
</div>
<button
:disabled=
"!snowflake || !secret"
@
click=
"authenticateUser(snowflake, secret)"
>
Submit
<button
v-show=
"loggingIn"
@
click=
"authenticate(secret.trim())"
>
Authenticate
</button>
<div
v-show=
"login
Failed"
>
Authentication failed. Check ID or Secret.
</div
>
<button
v-show=
"log
g
in
gIn"
@
click=
"loggingIn = false"
>
Back
</button
>
</div>
</section>
</
template
>
<
script
>
...
...
@@ -33,29 +19,23 @@ import { mapActions } from "vuex";
export
default
{
data
:
function
()
{
return
{
snowflake
:
""
,
loggingIn
:
false
,
secret
:
""
,
loginFailed
:
false
,
};
},
// 6813039343691657216
// tKUfNCawFlQSSkhmjyFfWErgqBkdXzbIBwcNrpAOoUSpwyNbqUNwkRZsjkINkChU
methods
:
{
async
authenticate
User
(
snowflake
,
secret
)
{
async
authenticate
(
secret
)
{
try
{
const
response
=
await
fetch
(
`/api/user/
${
snowflake
}
/secret
`
,
{
const
response
=
await
fetch
(
`/api/user/
this
`
,
{
headers
:
{
secret
:
secret
},
});
const
serverSecret
=
await
response
.
text
();
if
(
secret
===
serverSecret
)
{
console
.
log
(
"
Authenticated successfully
"
);
this
.
saveStateSnowflake
(
snowflake
);
const
data
=
await
response
.
json
();
if
(
response
.
ok
)
{
this
.
saveStateSnowflake
(
data
.
id
);
this
.
saveStateSecret
(
secret
);
this
.
snowflake
=
""
;
this
.
secret
=
""
;
console
.
log
(
"
Authenticated successfully
"
);
}
else
{
console
.
log
(
"
Please check ID or Secret Token
"
);
this
.
loginFailed
=
true
;
console
.
error
(
"
Authenticated failed
"
);
}
}
catch
{
(
error
)
=>
console
.
error
(
"
Something went terribly wrong...
"
,
error
);
...
...
@@ -65,6 +45,3 @@ export default {
},
};
</
script
>
\ No newline at end of file
<
style
scoped
>
</
style
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/router/index.js
+
0
−
6
View file @
01a78b0b
...
...
@@ -2,7 +2,6 @@ import Vue from 'vue'
import
VueRouter
from
'
vue-router
'
import
Home
from
'
../views/Home.vue
'
import
ImageView
from
'
../views/ImageView.vue
'
import
User
from
'
../views/User.vue
'
Vue
.
use
(
VueRouter
)
...
...
@@ -17,11 +16,6 @@ const routes = [
name
:
'
ImageView
'
,
component
:
ImageView
,
},
{
path
:
'
/user
'
,
name
:
'
User
'
,
component
:
User
,
}
]
const
router
=
new
VueRouter
({
...
...
This diff is collapsed.
Click to expand it.
src/views/Home.vue
+
5
−
2
View file @
01a78b0b
...
...
@@ -4,7 +4,8 @@
<div>
<TagCreation></TagCreation>
<ImageUpload
@
image-submitted=
"updateHashArray"
></ImageUpload>
<router-link
id=
"user-settings"
to=
"/user"
>
User settings
</router-link>
<!--
<router-link
id=
"user-settings"
to=
"/user"
>
User settings
</router-link>
-->
<UserAuthentication
id=
"auth"
></UserAuthentication>
</div>
</section>
<ImageList
:hashArray=
"stateHashArray"
></ImageList>
...
...
@@ -15,6 +16,7 @@
import
ImageList
from
"
@/components/ImageList.vue
"
;
import
ImageUpload
from
"
@/components/ImageUpload.vue
"
;
import
TagCreation
from
"
@/components/TagCreation.vue
"
;
import
UserAuthentication
from
"
@/components/UserAuthentication.vue
"
;
import
{
mapState
,
mapActions
}
from
"
vuex
"
;
export
default
{
...
...
@@ -22,6 +24,7 @@ export default {
ImageList
,
ImageUpload
,
TagCreation
,
UserAuthentication
,
},
computed
:
{
...
mapState
([
"
stateHashArray
"
]),
...
...
@@ -56,7 +59,7 @@ export default {
display
:
flex
;
flex-flow
:
row
;
}
#
user-settings
{
#
auth
{
position
:
absolute
;
bottom
:
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment