Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
project_ss23_gameunity
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Yusuf Akgül
project_ss23_gameunity
Commits
17b0344a
Commit
17b0344a
authored
1 year ago
by
Caner
Browse files
Options
Downloads
Patches
Plain Diff
EmailVerification ohne Password reset
parent
64f2341a
No related branches found
Branches containing commit
No related tags found
1 merge request
!45
Email verify
Pipeline
#39904
passed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/api/passwordChange/route.ts
+0
-52
0 additions, 52 deletions
app/api/passwordChange/route.ts
components/user-auth-form.tsx
+1
-1
1 addition, 1 deletion
components/user-auth-form.tsx
lib/validations/sendPasswordResetEmail.ts
+0
-26
0 additions, 26 deletions
lib/validations/sendPasswordResetEmail.ts
with
1 addition
and
79 deletions
app/api/passwordChange/route.ts
deleted
100644 → 0
+
0
−
52
View file @
64f2341a
import
nodemailer
from
"
nodemailer
"
;
import
{
NextResponse
}
from
"
next/server
"
;
import
{
db
}
from
"
@/lib/db
"
;
import
{
randomUUID
}
from
"
crypto
"
;
import
getURL
from
"
@/lib/utils
"
;
export
async
function
POST
(
req
:
Request
)
{
const
{
email
}
=
await
req
.
json
();
const
transporter
=
nodemailer
.
createTransport
({
service
:
'
gmail
'
,
host
:
'
smtp.gmail.com
'
,
auth
:
{
user
:
process
.
env
.
NODEMAIL_MAIL
,
pass
:
process
.
env
.
NODEMAIL_PW
,
},
});
const
user
=
await
db
.
user
.
findFirst
({
where
:
{
email
:
email
}
});
const
token
=
await
db
.
activationToken
.
create
({
data
:
{
token
:
`
${
randomUUID
()}${
randomUUID
()}
`
.
replace
(
/-/g
,
''
),
userId
:
user
?.
id
!
},
});
const
mailData
=
{
from
:
process
.
env
.
NODEMAIL_MAIL
,
to
:
email
,
subject
:
` 'Password Reset for your GameUnity account`
,
html
:
`Hello
${
user
?.
name
}
you requeste a password reset. \nPlease follow the Link:
${
getURL
(
`/api/verification/
${
token
.
token
}
`
)}
to change your password.`
,
};
let
emailRes
;
try
{
emailRes
=
await
transporter
.
sendMail
(
mailData
);
console
.
log
(
"
Message sent
"
,
emailRes
.
messageId
);
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
error
(
"
Error email could not be send
"
);
}
console
.
log
(
emailRes
?.
messageId
)
return
NextResponse
.
json
({
success
:
true
,
messageId
:
emailRes
?.
messageId
});
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
components/user-auth-form.tsx
+
1
−
1
View file @
17b0344a
...
...
@@ -94,7 +94,7 @@ export function UserAuthForm({ type, className, ...props }: UserAuthFormProps) {
}
if
(
signInResult
.
error
===
"
Email is not verified
"
)
{
return
toast
({
title
:
"
Please
V
erify your account.
"
,
title
:
"
Please
v
erify your account.
"
,
description
:
"
We send you a email to verify your Account. Please check your Mailbox!🚀
"
,
})
}
...
...
This diff is collapsed.
Click to expand it.
lib/validations/sendPasswordResetEmail.ts
deleted
100644 → 0
+
0
−
26
View file @
64f2341a
export
async
function
sendPasswordResetEmail
(
email
:
string
)
{
try
{
const
res
=
await
fetch
(
'
/api/passwordChange
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
({
email
,
}),
});
if
(
res
.
ok
)
{
alert
(
`PasswordChange Email was send 🚀`
);
}
if
(
res
.
status
===
400
)
{
alert
(
`Something went wrong! Password reset Email could not be send 😢`
);
}
}
catch
(
err
)
{
console
.
log
(
'
Something went wrong:
'
,
err
);
}
}
\ No newline at end of file
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