mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-15 18:02:13 +00:00
use urlTemplate for emails, fix error i18n
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
} from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { User, UserState } from "@zitadel/proto/zitadel/user/v2/user_pb";
|
||||
import { AuthenticationMethodType } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
||||
import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getSessionCookieByLoginName } from "../cookies";
|
||||
|
||||
@@ -27,6 +28,8 @@ type ResetPasswordCommand = {
|
||||
};
|
||||
|
||||
export async function resetPassword(command: ResetPasswordCommand) {
|
||||
const host = headers().get("host");
|
||||
|
||||
const users = await listUsers({
|
||||
loginName: command.loginName,
|
||||
organizationId: command.organization,
|
||||
@@ -41,7 +44,7 @@ export async function resetPassword(command: ResetPasswordCommand) {
|
||||
}
|
||||
const userId = users.result[0].userId;
|
||||
|
||||
return passwordReset(userId);
|
||||
return passwordReset(userId, host);
|
||||
}
|
||||
|
||||
export type UpdateSessionCommand = {
|
||||
|
||||
@@ -492,16 +492,24 @@ export function createUser(
|
||||
* @param userId the id of the user where the email should be set
|
||||
* @returns the newly set email
|
||||
*/
|
||||
export async function passwordReset(userId: string) {
|
||||
export async function passwordReset(userId: string, host: string | null) {
|
||||
return userService.passwordReset(
|
||||
{
|
||||
userId,
|
||||
medium: {
|
||||
case: "sendLink",
|
||||
value: {
|
||||
notificationType: NotificationType.Email,
|
||||
},
|
||||
},
|
||||
medium: host
|
||||
? {
|
||||
case: "sendLink",
|
||||
value: {
|
||||
notificationType: NotificationType.Email,
|
||||
urlTemplate: `https://${host}/password/set?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}`,
|
||||
},
|
||||
}
|
||||
: {
|
||||
case: "sendLink",
|
||||
value: {
|
||||
notificationType: NotificationType.Email,
|
||||
},
|
||||
},
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user