Commit df7e035e authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files

Se hizo la implementacion del metodo de cambio de contraseña en los datasource...

Se hizo la implementacion del metodo de cambio de contraseña en los datasource y repositorios de perfil
parent 0712ec8f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@ export class ProfileDataSourceDev implements ProfileDataSource {
        ];
    }

    async changePassword(oldPassword: string, newPassword: string): Promise<void> {
        console.log('Changing password', oldPassword, newPassword);
    }

    async saveInterests(options: IOption[]): Promise<void> {
        console.log('Saving interests', options);
    }
+26 −0
Original line number Diff line number Diff line
import axios from "axios";
import { IOption } from "../../../../common/domain/entities/option";
import { ProfileDataSource } from "../../../domain/datasources/profile_datasource";
import { API_URL } from "../../../../common/constants/api";

export class ProfileDataSourceProd implements ProfileDataSource {
    async getInterests(): Promise<IOption[]> {
        throw new Error('Method not implemented.');
    }

    async saveInterests(options: IOption[]): Promise<void> {
        throw new Error('Method not implemented.');
    }

    async setUpProfile(birthdate: string, interests: IOption[]): Promise<void> {
        throw new Error('Method not implemented.');
    }
    
    async changePassword(oldPassword: string, newPassword: string): Promise<void> {
        const {status, data} = await axios.patch(`${API_URL}/user/change-password`, {
            prevPassword: oldPassword,
            newPassword: newPassword
        })
        console.log(status, data);
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ export class ProfileRepositoryImpl implements ProfileRepository {
    constructor(
        private dataSource: ProfileDataSource
    ){}
    async changePassword (oldPassword: string, newPassword: string): Promise<void> {
        return this.dataSource.changePassword(oldPassword, newPassword);
    };
    async getInterests() {
        return this.dataSource.getInterests();
    }