Extend Login Request
This commit is contained in:
parent
a9e1a15183
commit
fd5364ff97
5 changed files with 41 additions and 15 deletions
|
|
@ -76,8 +76,7 @@ public class PlatformAccountAppService : AccountAppService, IAccountAppService
|
||||||
var SenderName = await settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName);
|
var SenderName = await settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName);
|
||||||
var SenderEmailAddress = await settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress);
|
var SenderEmailAddress = await settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress);
|
||||||
|
|
||||||
var url = await appUrlProvider.GetUrlAsync("MVC", PlatformConsts.Urls.UserDetail);
|
var userDetailUrl = await GetUserDetailUrlAsync(user.Id);
|
||||||
var userDetailUrl = $"{url}/{user.Id}";
|
|
||||||
|
|
||||||
var content = $@"My name is: {user.GetFullName()}.
|
var content = $@"My name is: {user.GetFullName()}.
|
||||||
Email Address: {user.Email}
|
Email Address: {user.Email}
|
||||||
|
|
@ -111,17 +110,16 @@ User Detail: {userDetailUrl}";
|
||||||
}
|
}
|
||||||
|
|
||||||
[Captcha]
|
[Captcha]
|
||||||
public async Task SendExtendLoginRequestAsync(SendExtendLoginRequestInputDto input)
|
public async Task<bool> SendExtendLoginRequestAsync(SendExtendLoginRequestInputDto input)
|
||||||
{
|
{
|
||||||
var user = await UserManager.FindByEmailAsync(input.EmailAddress);
|
var user = await UserManager.FindByEmailAsync(input.EmailAddress);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var userDetailUrl = await appUrlProvider.GetUrlAsync(PlatformConsts.React, PlatformConsts.Urls.UserDetail);
|
|
||||||
var content = $@"My name is: {user.GetFullName()}.
|
var content = $@"My name is: {user.GetFullName()}.
|
||||||
User Detail: {string.Format(userDetailUrl, user.Id)}";
|
User Detail: {await GetUserDetailUrlAsync(user.Id)}";
|
||||||
|
|
||||||
var recipient = await settingProvider.GetOrNullAsync(PlatformConsts.AbpSettings.SiteManagement.General.TimedLoginEmails);
|
var recipient = await settingProvider.GetOrNullAsync(PlatformConsts.AbpSettings.SiteManagement.General.TimedLoginEmails);
|
||||||
if (!recipient.IsNullOrWhiteSpace())
|
if (!recipient.IsNullOrWhiteSpace())
|
||||||
|
|
@ -132,9 +130,11 @@ User Detail: {string.Format(userDetailUrl, user.Id)}";
|
||||||
null,
|
null,
|
||||||
content,
|
content,
|
||||||
subject: PlatformConsts.AppName + " : Extend Login Request");
|
subject: PlatformConsts.AppName + " : Extend Login Request");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Captcha]
|
[Captcha]
|
||||||
|
|
@ -207,6 +207,15 @@ To validate your account, please complete your profile by clicking (or copy-past
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> GetUserDetailUrlAsync(Guid userId)
|
||||||
|
{
|
||||||
|
var url = await appUrlProvider.GetUrlAsync(PlatformConsts.React, PlatformConsts.Urls.UserDetail);
|
||||||
|
|
||||||
|
return url.Contains("{0}", StringComparison.Ordinal)
|
||||||
|
? string.Format(url, userId)
|
||||||
|
: $"{url.TrimEnd('/')}/{userId}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@
|
||||||
"descriptionKey": "App.SiteManagement.General.NewMemberNotificationEmails.Description",
|
"descriptionKey": "App.SiteManagement.General.NewMemberNotificationEmails.Description",
|
||||||
"defaultValue": "system@sozsoft.com",
|
"defaultValue": "system@sozsoft.com",
|
||||||
"isVisibleToClients": false,
|
"isVisibleToClients": false,
|
||||||
"providers": "G|D",
|
"providers": "T|G|D",
|
||||||
"isInherited": false,
|
"isInherited": false,
|
||||||
"isEncrypted": false,
|
"isEncrypted": false,
|
||||||
"mainGroupKey": "App.SiteManagement",
|
"mainGroupKey": "App.SiteManagement",
|
||||||
|
|
@ -276,7 +276,7 @@
|
||||||
"descriptionKey": "App.SiteManagement.General.TimedLoginEmails.Description",
|
"descriptionKey": "App.SiteManagement.General.TimedLoginEmails.Description",
|
||||||
"defaultValue": "system@sozsoft.com",
|
"defaultValue": "system@sozsoft.com",
|
||||||
"isVisibleToClients": false,
|
"isVisibleToClients": false,
|
||||||
"providers": "G|D",
|
"providers": "T|G|D",
|
||||||
"isInherited": false,
|
"isInherited": false,
|
||||||
"isEncrypted": false,
|
"isEncrypted": false,
|
||||||
"mainGroupKey": "App.SiteManagement",
|
"mainGroupKey": "App.SiteManagement",
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ public class PlatformHttpApiHostModule : AbpModule
|
||||||
options.Applications[PlatformConsts.React].RootUrl = configuration["App:ClientUrl"];
|
options.Applications[PlatformConsts.React].RootUrl = configuration["App:ClientUrl"];
|
||||||
options.Applications[PlatformConsts.React].Urls[PlatformConsts.Urls.EmailConfirmation] = "confirm";
|
options.Applications[PlatformConsts.React].Urls[PlatformConsts.Urls.EmailConfirmation] = "confirm";
|
||||||
options.Applications[PlatformConsts.React].Urls[PlatformConsts.Urls.PasswordReset] = "reset-password";
|
options.Applications[PlatformConsts.React].Urls[PlatformConsts.Urls.PasswordReset] = "reset-password";
|
||||||
options.Applications[PlatformConsts.React].Urls[PlatformConsts.Urls.UserDetail] = "account/{0}";
|
options.Applications[PlatformConsts.React].Urls[PlatformConsts.Urls.UserDetail] = "admin/users/detail";
|
||||||
|
|
||||||
//options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
|
//options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
|
||||||
//options.Applications["MVC"].Urls[PlatformConsts.Urls.EmailConfirmation] = "Account/Confirm";
|
//options.Applications["MVC"].Urls[PlatformConsts.Urls.EmailConfirmation] = "Account/Confirm";
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ export const verifyAccountConfirmationCode = (userId: string, token: string) =>
|
||||||
})
|
})
|
||||||
|
|
||||||
export const sendExtendLoginRequest = (data: any) =>
|
export const sendExtendLoginRequest = (data: any) =>
|
||||||
apiService.fetchData({
|
apiService.fetchData<boolean>({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: 'api/app/platform-account/send-extend-login-request',
|
url: 'api/app/platform-account/send-extend-login-request',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ import Input from '@/components/ui/Input'
|
||||||
import { APP_NAME } from '@/constants/app.constant'
|
import { APP_NAME } from '@/constants/app.constant'
|
||||||
import { ROUTES_ENUM } from '@/routes/route.constant'
|
import { ROUTES_ENUM } from '@/routes/route.constant'
|
||||||
import { sendExtendLoginRequest } from '@/services/account.service'
|
import { sendExtendLoginRequest } from '@/services/account.service'
|
||||||
import { store } from '@/store'
|
import { store, useStoreActions } from '@/store'
|
||||||
import { useLocalization } from '@/utils/hooks/useLocalization'
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
||||||
import useTimeOutMessage from '@/utils/hooks/useTimeOutMessage'
|
import useTimeOutMessage from '@/utils/hooks/useTimeOutMessage'
|
||||||
import { TurnstileInstance } from '@marsidev/react-turnstile'
|
import { TurnstileInstance } from '@marsidev/react-turnstile'
|
||||||
import { Field, Form, Formik } from 'formik'
|
import { Field, Form, Formik } from 'formik'
|
||||||
import { useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { Helmet } from 'react-helmet'
|
import { Helmet } from 'react-helmet'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
|
|
@ -36,8 +36,13 @@ const ExtendLogin = () => {
|
||||||
|
|
||||||
const [message, setMessage] = useTimeOutMessage(10000)
|
const [message, setMessage] = useTimeOutMessage(10000)
|
||||||
const { translate } = useLocalization()
|
const { translate } = useLocalization()
|
||||||
|
const { setWarning } = useStoreActions((actions) => actions.base.messages)
|
||||||
const captchaRef = useRef<TurnstileInstance>(null)
|
const captchaRef = useRef<TurnstileInstance>(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setWarning('')
|
||||||
|
}, [setWarning])
|
||||||
|
|
||||||
const onSendMail = async (
|
const onSendMail = async (
|
||||||
values: ExtendLoginFormSchema,
|
values: ExtendLoginFormSchema,
|
||||||
setSubmitting: (isSubmitting: boolean) => void,
|
setSubmitting: (isSubmitting: boolean) => void,
|
||||||
|
|
@ -46,10 +51,22 @@ const ExtendLogin = () => {
|
||||||
const { email, captchaResponse } = values
|
const { email, captchaResponse } = values
|
||||||
setSubmitting(true)
|
setSubmitting(true)
|
||||||
try {
|
try {
|
||||||
await sendExtendLoginRequest({ email, captchaResponse })
|
const result = await sendExtendLoginRequest({ email, captchaResponse })
|
||||||
|
if (result.data !== true) {
|
||||||
|
throw new Error(
|
||||||
|
'Your request could not be sent. Please check the email address and try again.',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
setWarning('')
|
||||||
setEmailSent(true)
|
setEmailSent(true)
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
setMessage(error?.response?.data || error.toString())
|
setMessage(
|
||||||
|
error?.response?.data?.error?.message ||
|
||||||
|
error?.response?.data?.message ||
|
||||||
|
error?.message ||
|
||||||
|
error.toString(),
|
||||||
|
)
|
||||||
} finally {
|
} finally {
|
||||||
setFieldValue('captchaResponse', '')
|
setFieldValue('captchaResponse', '')
|
||||||
captchaRef.current?.reset()
|
captchaRef.current?.reset()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue