Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cloud_Computing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Tim Hobelsberger
Cloud_Computing
Commits
8179eaaf
Commit
8179eaaf
authored
Oct 29, 2022
by
Markus Klose
Browse files
Options
Downloads
Patches
Plain Diff
Registration redirect, empty form check
parent
d5f29dee
Branches
Branches containing commit
No related tags found
1 merge request
!5
Redirect
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
views/register.html
+108
-6
108 additions, 6 deletions
views/register.html
with
108 additions
and
6 deletions
views/register.html
+
108
−
6
View file @
8179eaaf
...
...
@@ -24,16 +24,20 @@
event
.
preventDefault
();
var
username
=
document
.
getElementById
(
"
username
"
).
value
;
var
password
=
document
.
getElementById
(
"
password
"
).
value
;
var
username
=
document
.
getElementById
(
"
username
"
);
var
password
=
document
.
getElementById
(
"
password
"
);
// Check if input Login and Password are empty
//
if
(
username
.
value
.
trim
().
length
&&
password
.
value
.
trim
().
length
!==
0
)
{
console
.
log
(
username
,
password
);
var
myHeaders
=
new
Headers
();
myHeaders
.
append
(
"
Content-Type
"
,
"
application/json
"
);
var
raw
=
JSON
.
stringify
({
"
name
"
:
username
,
"
password
"
:
password
"
name
"
:
username
.
value
.
trim
()
,
"
password
"
:
password
.
value
.
trim
()
});
var
requestOptions
=
{
...
...
@@ -47,11 +51,109 @@
.
then
((
response
)
=>
{
if
(
response
.
status
==
200
){
console
.
log
(
"
200
"
);
if
(
document
.
getElementById
(
"
divLeer
"
))
{
console
.
log
(
"
drinne
"
);
var
divLeer
=
document
.
getElementById
(
"
divLeer
"
);
divLeer
.
parentNode
.
removeChild
(
divLeer
);
}
var
divErfolgreich
=
document
.
createElement
(
'
div
'
);
divErfolgreich
.
textContent
=
"
Erfolgreich registriert!
"
;
document
.
body
.
appendChild
(
divErfolgreich
);
const
button
=
document
.
createElement
(
"
button
"
);
button
.
setAttribute
(
"
id
"
,
"
loginButton
"
);
button
.
innerText
=
"
Zum Login
"
;
button
.
type
=
"
submit
"
;
button
.
name
=
"
button
"
;
button
.
classList
.
add
(
"
button
"
);
button
.
addEventListener
(
"
click
"
,
()
=>
{
window
.
location
.
href
=
"
/login
"
;
});
document
.
body
.
appendChild
(
button
);
}
})
.
then
((
result
)
=>
{})
.
catch
(
error
=>
console
.
log
(
'
error
'
,
error
));
}
else
{
username
.
value
=
""
;
password
.
value
=
""
;
var
divLeer
=
document
.
createElement
(
'
div
'
);
divLeer
.
setAttribute
(
"
id
"
,
"
divLeer
"
);
divLeer
.
textContent
=
"
Bitte fülle beide Felder aus
"
;
document
.
body
.
appendChild
(
divLeer
);
}
}
/* // Check if input Login and Password are empty
//
if (username.value.trim().length && password.value.trim().length === 0) {
username.value = "";
password.value = "";
var div = document.createElement('div');
div.textContent = "Bitte fülle beide Felder aus";
document.body.appendChild(div);
}
console.log(username, password);
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"name": username.value.trim(),
"password": password.value.trim()
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://localhost:3000/register", requestOptions)
.then((response) => {
if(response.status == 200){
console.log("200");
var div = document.createElement('div');
div.textContent = "Erfolgreich registriert!";
document.body.appendChild(div);
const button = document.createElement("button");
button.innerText = "Zum Login";
button.type = "submit";
button.name = "button";
button.classList.add("button");
button.addEventListener("click", () => {
window.location.href = "/login";
});
document.body.appendChild(button);
}
})
.catch(error => console.log('error', error));
} */
</script>
</body>
...
...
...
...
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
sign in
to comment