當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript bcrypt-nodejs.hashSync函數代碼示例

本文整理匯總了TypeScript中bcrypt-nodejs.hashSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript hashSync函數的具體用法?TypeScript hashSync怎麽用?TypeScript hashSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了hashSync函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: init

  async init(investor: Investor): Promise<KycInitResult> {
    const id = investor.id.toHexString();
    const hash = base64encode(bcrypt.hashSync(id + config.kyc.apiSecret));

    const kycOptions = {
      baseUrl: this.baseUrl,
      method: 'POST',
      auth: {
        user: this.apiToken,
        password: this.apiSecret
      },
      headers: {
        'User-Agent': 'JINCOR ICO/1.0.0'
      },
      body: {
        merchantIdScanReference: uuid.v4(),
        successUrl: `${ config.app.apiUrl }/kyc/uploaded/${ id }/${ hash }`,
        errorUrl: `${ config.app.frontendUrl }/dashboard/verification/failure`,
        callbackUrl: `${ config.app.apiUrl }/kyc/callback`,
        customerId: investor.email,
        authorizationTokenLifetime: this.defaultTokenLifetime
      }
    };

    return await request.json<KycInitResult>('/initiateNetverify', kycOptions);
  }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:26,代碼來源:kyc.client.ts

示例2: init

export function init(sequelize, DataTypes) {
    let fields = {
        id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true
        },
        email: {
            type: DataTypes.STRING
        },
        profile: {
            type: DataTypes.JSON //local, google, facebook
        }
    };

    let options = {
        classMethods: {
            generateHash(password) {
                return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
            },
        },
        instanceMethods: {
            getFullName() {
                return `${this.lastName}, ${this.firstName}`;
            }
        }
    };

    let model = helper.defineModel('user', fields, options, sequelize);

    return model;
}
開發者ID:Blocklevel,項目名稱:contoso-express,代碼行數:32,代碼來源:user.ts

示例3: next

 .then(valid => {
     if (valid) {
         DB.persistMemberChange(_id, { password: bcrypt.hashSync(request.body.first) })
             .then(() => response.end())
             .catch(next);
     } else {
         next(new Err.AuthenticationError(''));
     }
 })
開發者ID:roderickmonk,項目名稱:rod-monk-sample-repo-ng2,代碼行數:9,代碼來源:Server.ts

示例4: function

userSchema.pre('save', function(next) {
  let user = this;
  if(!user.isModified('password')){
    return next();
  }
  
  user.password = bcrypt.hashSync(user.password);
  return next();
});
開發者ID:BartoszSiemienczuk,項目名稱:teamsuite,代碼行數:9,代碼來源:user.ts

示例5: RegExp

	export const activateAccount = (member: MemberInterface): Promise<any> =>
		MemberModel.findOneAndUpdate(
			{
				firstname: { $in: new RegExp(`^${member.firstname}$`, 'i') },
				emailaddress: { $in: new RegExp(`^${member.emailaddress}$`, 'i') },
			},
			{
				password: bcrypt.hashSync(member.password),
				activated: true
			});
開發者ID:roderickmonk,項目名稱:rod-monk-sample-repo-ng2,代碼行數:10,代碼來源:DB.ts

示例6: AddPasswordSync

 AddPasswordSync(password: string): void {
     if (password) {
         let it = this;
         let round = (Math.floor(Math.random() * 10) + 1);
         Log.d("User", "AddPasswordSync", "Generating SaltSync", round);
         let salt = bcript.genSaltSync(round);
         Log.d("User", "AddPasswordSync", "Generating HashSync", salt);
         let hash = bcript.hashSync(password, salt);
         Log.d("User", "AddPasswordSync", "password encrypted", hash);
         it.Password = hash;
     }
 }
開發者ID:pteyssedre,項目名稱:lazy-uac,代碼行數:12,代碼來源:models.ts

示例7: setPasswordFn

        setPassword: function setPasswordFn(password: string) {
            const self: IUserInstance = this;
            if (!password) {
                throw new Error('Password Can\'t Be Null!');
            }

            const salt = bcrypt.genSaltSync();
            const encrypted = bcrypt.hashSync(password, salt);

            self.setDataValue('password', encrypted);

            return self.save();
        },
開發者ID:csgpro,項目名稱:csgpro.com,代碼行數:13,代碼來源:user.model.ts

示例8: done

                    .then((user) => {
                        if (user) {
                            // if the user is already exist
                            return done(null, false, { message: "The user is already exist" });
                        }

                        var newUser = new User();
                        newUser.email = email;
                        newUser.password = bcrypt.hashSync(password);

                        newUser.save().then((user) => {
                            return done(null, user);
                        }, (err) => {
                            throw err;
                        });
                    }, (err) => {
開發者ID:zzeneg,項目名稱:NodeSimpleWebsite,代碼行數:16,代碼來源:passport.ts

示例9: function

ConsumerSchema.pre('save', function(next: Function): void {
  let user = this

  if (user.isModified('password')) {
  // generate a salt then run callback
    let salt = bcrypt.genSaltSync(CONFIG.USER_SALT_LENGTH)
    user.password = bcrypt.hashSync(user.password, salt)
    user.updated = UTIL.getTimestamp()
  }
  
  if (user.isNew) {
    user.wasNew = user.isNew
  }

  next()
})
開發者ID:yeegr,項目名稱:SingularJS,代碼行數:16,代碼來源:ConsumerModel.ts


注:本文中的bcrypt-nodejs.hashSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。