基于 Angular 7 与 Firebase 5 构建安全的 Web 应用

使用 AngularFire2 库实现 Angular 7 与 Firebase 5 的用户身份验证

本教程将指导您使用 AngularFire2 库,基于 Angular 7 和 Firebase 5 创建全面的用户身份验证系统。

功能:

  • 使用 Google 账户登录
  • 使用 Facebook 账户登录
  • 使用用户名和密码注册
  • 忘记密码恢复
  • 向新用户发送验证邮件
  • 限制未验证用户访问应用仪表板
  • 限制未登录用户访问受保护页面
  • 阻止已登录用户访问登录和注册组件
  • 将用户数据存储在本地存储中

安装:

  1. 运行 npm install 安装项目依赖
  2. 运行 ng serve 启动开发服务器
  3. 访问 http://localhost:4200/

注意:修改源文件后,应用程序将自动重新加载。

代码示例:

//  示例: 使用 AngularFireAuth 服务进行电子邮件/密码登录
import { Component } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { auth } from 'firebase/app';

@Component({
  // ...
})
export class LoginComponent {
  constructor(public afAuth: AngularFireAuth) { }

  loginWithEmail(email: string, password: string) {
    return this.afAuth.auth.signInWithEmailAndPassword(email, password);
  }
}

贡献:

如果您喜欢本项目,请为仓库点亮 star,与更多开发者分享!

zip
angularfirebase-authentication-master.zip 预估大小:59个文件
folder
angularfirebase-authentication-master 文件夹
file
.angulardoc.json 71B
file
.browserslistrc 388B
folder
src 文件夹
file
tsconfig.spec.json 256B
file
main.ts 372B
file
index.html 418B
file
styles.css 9KB
file
polyfills.ts 3KB
folder
environments 文件夹
file
environment.ts 973B
file
environment.prod.ts 362B
file
favicon.ico 5KB
folder
assets 文件夹
file
dummy-user.png 910B
folder
.gitkeep 文件夹
file
logo-positronx-white.svg 15KB
file
tslint.json 314B
file
test.ts 642B
file
tsconfig.app.json 204B
folder
app 文件夹
folder
shared 文件夹
folder
services 文件夹
file
user.ts 131B
file
auth.service.ts 4KB
file
auth.service.spec.ts 323B
folder
guard 文件夹
file
auth.guard.ts 671B
folder
routing 文件夹
file
app-routing.module.ts 1KB
folder
app.component.css 文件夹
folder
components 文件夹
folder
forgot-password 文件夹
file
forgot-password.component.spec.ts 685B
file
forgot-password.component.html 769B
file
forgot-password.component.ts 409B
folder
forgot-password.component.css 文件夹
folder
dashboard 文件夹
folder
dashboard.component.css 文件夹
file
dashboard.component.html 2KB
file
dashboard.component.ts 489B
file
dashboard.component.spec.ts 649B
folder
verify-email 文件夹
file
verify-email.component.spec.ts 671B
file
verify-email.component.ts 396B
file
verify-email.component.html 1KB
folder
verify-email.component.css 文件夹
folder
sign-up 文件夹
file
sign-up.component.spec.ts 629B
file
sign-up.component.html 1KB
file
sign-up.component.ts 375B
folder
sign-up.component.css 文件夹
folder
sign-in 文件夹
file
sign-in.component.html 2KB
folder
sign-in.component.css 文件夹
file
sign-in.component.spec.ts 629B
file
sign-in.component.ts 375B
file
app.module.ts 2KB
file
app.component.html 31B
file
app.component.ts 234B
file
app.component.spec.ts 1KB
file
karma.conf.js 964B
file
angular.json 4KB
file
tsconfig.json 470B
file
tslint.json 3KB
file
README.md 1KB
file
.editorconfig 245B
file
.gitignore 503B
file
package-lock.json 615KB
folder
e2e 文件夹
file
tsconfig.e2e.json 213B
folder
src 文件夹
file
app.e2e-spec.ts 326B
file
app.po.ts 208B
file
protractor.conf.js 752B
file
package.json 1KB
...
zip 文件大小:196.33KB