新手在这里。我正在尝试为 java Spring Boot 应用程序编写重置密码功能。前端适用于 Angular 7。
用户输入他的电子邮件并单击重置按钮。然后,一个令牌存储在用户表中,用户会收到一封带有如下链接的邮件:
http://localhost:4200/reset-password?token=7f278bf1-40c7-4b1a-bde5-76744b866241
当我单击此链接时,出现 404 错误。该应用似乎找不到 ResetPasswordForm 组件。
重置密码form.module.ts:
import { ResetPasswordFormComponent } from './reset-password-form.component';
import { Routes, RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MaterialModule } from '../material/material.module';
import { ClassementModule } from '../classement/classement.module';
import { HttpClientModule } from '@angular/common/http';
const routes: Routes = [
{ path: 'reset-password', component: ResetPasswordFormComponent }
// { path: '', component: HomeComponent }
];
@NgModule({
declarations: [ResetPasswordFormComponent],
imports: [
CommonModule,
MaterialModule,
ClassementModule,
HttpClientModule,
RouterModule.forChild(routes)
]
})
export class ResetPasswordModule { }
应用程序路由.module.ts :
...
import { ResetPasswordFormComponent } from './site/reset-password-form/reset-password-form.component';
...
{ path: 'reset-password', component: ResetPasswordFormComponent}
...
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
app.module.ts
...
import { ResetPasswordModule } from './site/reset-password-form/reset-password-form.module';
...
@NgModule({
declarations: [
AppComponent,
ConfirmDialogComponent,
UserComponent,
AlertComponent,
],
imports: [
...
ResetPasswordModule
],
providers: [httpInterceptorProviders, {provide: LOCALE_ID, useValue: "fr-FR", }, DatePipe],
entryComponents: [ConfirmDialogComponent, AlertComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
重置密码form.component.ts
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../auth/auth.service';
@Component({
selector: 'app-reset-password-form',
templateUrl: './reset-password-form.component.html',
styleUrls: ['./reset-password-form.component.scss']
})
export class ResetPasswordFormComponent implements OnInit {
constructor(private authService: AuthService) { }
ngOnInit() {
if(this.authService.isLoggedIn) {
console.log("logged in")
}
else {
console.log("not logged in")
}
}
}
我使用这个功能已经好几天了,我很累,我想我做错了什么。你可以帮帮我吗?