npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@geekbears/gb-ngrx-account-basic

v17.0.16

Published

This library provides a robust NgRx-based state management solution for account-related features in Angular applications. It centralizes the logic for managing user profile information, password updates, email changes, and verification workflows, offering

Readme

@geekbears/gb-ngrx-account-basic

This library provides a robust NgRx-based state management solution for account-related features in Angular applications. It centralizes the logic for managing user profile information, password updates, email changes, and verification workflows, offering a predictable state container for your account data.

Features

  • Password Management:
    • Forgot Password: Complete flow for requesting password reset emails and submitting new passwords.
    • Change Password: Securely update the logged-in user's password.
  • Email Management:
    • Change Email: Process for updating user email addresses, including verification steps.
    • Verification: Handle email verification codes and resend requests.
  • Profile Management:
    • Update Info: seamless updates for general account information.
    • Profile Image: Dedicated flow for uploading and updating profile pictures.
  • State Management:
    • Loading & Error States: Built-in state tracking for all asynchronous operations.
    • Selectors: Easy access to account data and operation status.

Installation

Install the library using npm or yarn:

npm install @geekbears/gb-ngrx-account-basic
# or
yarn add @geekbears/gb-ngrx-account-basic

Configuration

The library requires a configuration object to define API endpoints and custom mappers. You must provide this configuration using the GbNgRxAccountConfigToken.

1. Define your Configuration

Create a class or object that implements GbNgRxAccountBasicModuleConfig:

import { GbNgRxAccountBasicModuleConfig, AccountUpdatePayload } from '@geekbears/gb-ngrx-account-basic';
import { AuthenticationData } from '@geekbears/gb-ngrx-auth-basic';
import { Observable } from 'rxjs';

export const myAccountConfig: GbNgRxAccountBasicModuleConfig = {
  // --- Profile Image ---
  updateAccountProfileImageApiUrl: (authData) => `${environment.apiUrl}/users/${authData.userId}/avatar`,
  updateAccountProfileImageRequestMapper: (file, authData) => {
    const formData = new FormData();
    formData.append('avatar', file);
    return of(formData);
  },

  // --- Account Info ---
  updateAccountInfoApiUrl: (authData) => `${environment.apiUrl}/users/${authData.userId}`,
  updateAccountInfoCustomRequestMapper: (authData, payload) => of(payload),
  getUserAccountInfoApiUrl: (userId) => `${environment.apiUrl}/users/${userId}`,
  
  // --- Response Parsers ---
  updateAccountInfoCustomResponseParser: (response) => of(response.data),
  updateUsernameCustomResponseParser: (response) => of(response.data),

  // --- Verification ---
  submitVerificationCodeApiUrl: (authData) => `${environment.apiUrl}/verify-code`,
  submitVerificationCodeCustomRequestMapper: (code, authData) => of({ code, userId: authData.userId }),
  
  resendVerificationCodeApiUrl: (authData) => `${environment.apiUrl}/resend-code`,
  resendVerificationCodeCustomRequestMapper: (authData) => of({ userId: authData.userId }),

  // --- Password Management ---
  requestForgotPasswordApiUrl: () => `${environment.apiUrl}/auth/forgot-password`,
  setNewForgottenPasswordApiUrl: () => `${environment.apiUrl}/auth/reset-password`,
  
  changePasswordApiUrl: (userId) => `${environment.apiUrl}/users/${userId}/password`,
  changePasswordCustomRequestMapper: (userId, data) => of(data),

  // --- Email Management ---
  changeEmailApiUrl: (userId) => `${environment.apiUrl}/users/${userId}/email`,
  changeEmailCustomRequestMapper: (userId, data) => of(data),
  
  submitEmailVerificationCodeApiUrl: (userId) => `${environment.apiUrl}/users/${userId}/email/verify`,
  submitEmailVerificationCodeCustomRequestMapper: (userId, code) => of({ code }),
  
  submitCancelEmailChangeApiUrl: (userId) => `${environment.apiUrl}/users/${userId}/email/cancel`,
  submitResendCodeEmailChangeApiUrl: (userId) => `${environment.apiUrl}/users/${userId}/email/resend`,
};

2. Import the Module

Import GbNgrxAccountBasicModule into your AppModule (or a Core module) and provide the configuration:

import { NgModule } from '@angular/core';
import { GbNgrxAccountBasicModule, GbNgRxAccountConfigToken } from '@geekbears/gb-ngrx-account-basic';
import { myAccountConfig } from './my-account.config';

@NgModule({
  imports: [
    // ... other imports
    GbNgrxAccountBasicModule,
  ],
  providers: [
    {
      provide: GbNgRxAccountConfigToken,
      useValue: myAccountConfig
    }
  ],
})
export class AppModule { }

Usage

Dispatching Actions

Interact with the state by dispatching actions from your components or services.

import { Store } from '@ngrx/store';
import { 
  updateAccountInfoAction, 
  changePasswordAction, 
  requestPasswordResetAction 
} from '@geekbears/gb-ngrx-account-basic';

@Component({ ... })
export class MyProfileComponent {
  constructor(private store: Store) {}

  updateProfile(info: any) {
    this.store.dispatch(updateAccountInfoAction({ info }));
  }

  changePassword(oldPassword: string, newPassword: string) {
    this.store.dispatch(changePasswordAction({ 
      userId: '123', 
      data: { oldPassword, newPassword } 
    }));
  }
}

Selecting State

Use selectors to observe data from the store.

import { Store } from '@ngrx/store';
import { selectAccountState, selectIsUpdatingAccount } from '@geekbears/gb-ngrx-account-basic';

@Component({ ... })
export class MyProfileComponent {
  accountState$ = this.store.select(selectAccountState);
  isLoading$ = this.store.select(selectIsUpdatingAccount);

  constructor(private store: Store) {}
}

API Reference

Key Selectors

  • selectAccountState: Returns the entire account feature state.
  • selectAccountUser: Returns the current user object.
  • selectIsUpdatingAccount: Boolean indicating if an update is in progress.
  • selectAccountError: Returns any error from the last operation.

Key Actions

  • updateAccountInfoAction
  • updateAccountProfileImageAction
  • submitPasswordChangeAction
  • submitEmailChangeAction
  • requestPasswordResetAction
  • submitVerificationCodeAction