在登录页面添加 "Remember me" 复选框

Add "Remember me" checkbox to the login page

如何向登录表单添加新字段,例如“记住我”。开箱即用不支持哪个?

现在登录表单仅提供“电子邮件”和“密码”字段,我在 ngOnInit 方法中使用新的 FormControl remember 扩展了表单,但我无法传递接收到的值到 auth.authorize 方法,因为此方法不需要新值。

import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormControl, Validators} from '@angular/forms';
import {ActivatedRoute} from '@angular/router';
import {AuthRedirectService, AuthService, GlobalMessageService, WindowRef} from '@spartacus/core';

import {CheckoutConfigService, LoginFormComponent} from '@spartacus/storefront';


@Component({
  selector: 'app-app-login-form',
  templateUrl: './app-login-form.component.html',
  styleUrls: ['./app-login-form.component.scss']
})
export class AppLoginFormComponent extends LoginFormComponent implements OnInit {

  constructor(
    auth: AuthService,
    globalMessageService: GlobalMessageService,
    fb: FormBuilder,
    authRedirectService: AuthRedirectService,
    winRef: WindowRef,
    activatedRoute: ActivatedRoute,
    checkoutConfigService: CheckoutConfigService,
  ) {
    super(auth, globalMessageService, fb, authRedirectService, winRef, activatedRoute, checkoutConfigService);

    auth.authorize('email.email.com', '123', true);
  }

  ngOnInit(): void {
    super.ngOnInit();

    this.loginForm.addControl('remember', new FormControl('', Validators.required));
  }
}

环境: 斯巴达克斯 3.0

Screenshot was given from Spartacus 2, but I'm sure you that is the same contract/problem for Spartacus 3.

需要覆盖AuthService并添加内部变量,然后再读取。