How to create a reset password feature in symfony 7 with Api Platform

I am using Symfony & Api Platform with docker, and I am trying to create a reset password feature in my application that also sends a mail when its succesfull. I have installed a package called ‘CoopTilleulsForgotPasswordBundle’.

I read and followed the instructions from their github https://github.com/coopTilleuls/CoopTilleulsForgotPasswordBundle/tree/main

After setting everything up according to the documentation that is provided.

I tested it with loading ‘Fixtures’ fake data( symfony console doctrine:fixtures:load ).
And then I used Postman to try it out with fake data that had been loaded to my database thanks to fixtures.

But When I send a Post request with a body,

[email => fake_email@from_database.com]

to the route: ‘localhost::80/api/forgot-password/’

I receive: ‘{“message”:”No parameter sent.”}’

This is kind if confusing because I did not really understand what it meant.
I hoped and expected some token back as verification that it found the email.

I am not to familiar with Symfony but I really want to try it out for the project I am working on.

As I mentioned It confused me as I didnt understood what I should do to solve this.

I tried adding a parameter with a provider from ‘config/packages/coop_tilleuls_forgot_password.yaml’ when sending the email


# config/packages/coop_tilleuls_forgot_password.yaml
coop_tilleuls_forgot_password:
    providers: 
        customer:
            default: true
            password_token:
                class: 'AppEntityPasswordToken' # required
                expires_in: '1 day'
                user_field: 'user'
                serialization_groups: []
            user:
                class: 'AppEntityUser' # required
                email_field: 'email'

According to the documentation the key should be ‘FP-provider’ with value of a provider.

FP-provider => customer

But I am still getting the same message ‘No parameter found’.

I then tried create a GetTokenController

namespace AppControllerApi;
use SymfonyComponentHttpFoundationResponse;
final class GetTokenController
{
    public function __invoke(): Response
    {
        // return new Response('', Response::HTTP_NO_CONTENT);
        return new Response('Testing', Response::HTTP_OK);
    }
}

At the moment I am kind of stuck trying to create api endpoint(s) that provide a reset feature in my application.

Config > Packages > Security.yaml

access_control:
        - { path: '^/api/forgot-password', role: PUBLIC_ACCESS }

SRC > Entity > passwordToken.php

<?php
namespace AppEntity;
use CoopTilleulsForgotPasswordBundleEntityAbstractPasswordToken;
use DoctrineORMMapping as ORM;
#[ORMEntity]
class PasswordToken extends AbstractPasswordToken
{
    #[ORMId]
    #[ORMColumn(type: 'integer', nullable: false)]
    #[ORMGeneratedValue(strategy: 'AUTO')]
    private ?int $id = null;
    #[ORMManyToOne(targetEntity: User::class)]
    #[ORMJoinColumn(nullable: false, name: 'user_id')]
    private $user;
    public function getId(): ?int
    {
        return $this->id;
    }
    public function getUser()
    {
        return $this->user;
    }
    /**
     * @param User $user
     */
    public function setUser($user): void
    {
        $this->user = $user;
    }
}

Config > Packages > coop_tilleuls_forgot_password.yaml

coop_tilleuls_forgot_password:
    providers: 
        customer:
            default: true
            password_token:
                class: 'AppEntityPasswordToken' # required
                expires_in: '1 day'
                user_field: 'user'
                serialization_groups: []
            user:
                class: 'AppEntityUser' # required
                email_field: 'email'
                password_field: 'password'

Config > Routes > coop_tilleuls_forgot_password.yaml

coop_tilleuls_forgot_password:
    resource: "@CoopTilleulsForgotPasswordBundle/Resources/config/routing.xml"
    # prefix:   /forgot_password
    # resource: .
    type: coop_tilleuls_forgot_password
    prefix: '/api/forgot-password'

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật