Skip to content

Instantly share code, notes, and snippets.

View Emiklad24's full-sized avatar

Emmanuel Nnajiofor Emiklad24

View GitHub Profile
@Emiklad24
Emiklad24 / useBroadcastLeader.ts
Created June 4, 2021 14:57 — forked from tannerlinsley/useBroadcastLeader.ts
A React Hook to determine if a tab of your application is the "leader" using BroadcastChannel and leader election
import { BroadcastChannel, createLeaderElection } from 'broadcast-channel'
import React from 'react'
const channels = {}
export function useBroadcastLeader(id = 'default') {
const [isBroadcastLeader, setIsBroadcastLeader] = React.useState(false)
React.useEffect(() => {
if (!channels[id]) {
@Emiklad24
Emiklad24 / auth.changePassword.js
Created June 26, 2020 09:56 — forked from psi-4ward/auth.changePassword.js
Feathers.js simple changePassword Service
const auth = require('@feathersjs/authentication');
const errors = require('@feathersjs/errors');
const bcrypt = require('bcryptjs');
const comparePasswords = (oldPassword, password) => new Promise((resolve, reject) => {
bcrypt.compare(oldPassword, password, (err, data1) => {
if(err || !data1) return reject();
return resolve();
});
});