本文整理汇总了TypeScript中server/libs/utils.getHashPassword函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getHashPassword函数的具体用法?TypeScript getHashPassword怎么用?TypeScript getHashPassword使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getHashPassword函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: isConfirmSignupEmailValid
export function isConfirmSignupEmailValid(param : Request.ConfirmSignupEmail, account : Account, locale : string) : ValidationResult
{
const log = slog.stepIn('SignupApi', 'isConfirmSignupEmailValid');
const response : Response.ConfirmSignupEmail = {status:Response.Status.OK, message:{}};
do
{
if (account === null)
{
// サインアップの確認画面でサインアップを完了させた後、再度サインアップを完了させようとした場合にここに到達する想定。
// サインアップIDで該当するアカウントがないということが必ずしもサインアップ済みを意味するわけではないが、
// 第三者が直接このAPIをコールするなど、想定以外のケースでなければありえないので、登録済みというメッセージでOK。
response.status = Response.Status.FAILED;
response.message.general = R.text(R.ALREADY_SIGNUP, locale);
break;
}
const hashPassword = Utils.getHashPassword(account.email, param.password, Config.PASSWORD_SALT);
if (account.password !== hashPassword)
{
response.status = Response.Status.FAILED;
response.message.password = R.text(R.INVALID_PASSWORD, locale);
}
}
while (false);
if (response.status !== Response.Status.OK) {
log.w(JSON.stringify(response, null, 2));
}
log.stepOut();
return {response};
}
开发者ID:nandai,项目名称:web-service-template,代码行数:34,代码来源:onConfirmSignupEmail.ts
示例2: async
test.serial('パスワード変更の入力値検証 - メールアドレス以外に認証手段がある時はパスワードなしに変更できること', async (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
let account : Account =
{
email: '[email protected]',
password: '12345678',
twitter: 'twitter'
};
account.password = Utils.getHashPassword(account.email, account.password, Config.PASSWORD_SALT);
account = await AccountAgent.add(account);
const param : Request.ChangePassword =
{
oldPassword: '12345678',
newPassword: null,
confirm: null,
};
const result = await isChangePasswordValid(param, account.id, locale);
const {status} = result.response;
t.is(status, Response.Status.OK);
await AccountAgent.remove(account.id);
log.stepOut();
});
开发者ID:nandai,项目名称:web-service-template,代码行数:25,代码来源:_testIsChangePasswordValid.ts
示例3: onLoginEmail
export async function onLoginEmail(req : express.Request, res : express.Response)
{
const log = slog.stepIn('LoginApi', 'onLoginEmail');
try
{
do
{
const locale = req.ext.locale;
const param : Request.LoginEmail = req.body;
const condition : Request.LoginEmail =
{
email: ['string', null, true] as any,
password: ['string', null, true] as any
};
if (Utils.existsParameters(param, condition) === false)
{
res.ext.badRequest(locale);
break;
}
const {email, password} = param;
const account = await AccountAgent.findByProviderId('email', email);
let hashPassword : string;
if (account) {
hashPassword = Utils.getHashPassword(email, password, Config.PASSWORD_SALT);
}
if (account === null || account.password !== hashPassword || account.signup_id)
{
const response : Response.LoginEmail =
{
status: Response.Status.FAILED,
message: {general:R.text(R.INVALID_EMAIL_AUTH, locale)}
};
log.w(JSON.stringify(response, null, 2));
res.json(response);
break;
}
process.nextTick(() =>
{
Email.verify(email, hashPassword, (_err, user) =>
{
req.ext.command = 'login';
req.user = user;
Email.callback(req, res);
});
});
}
while (false);
log.stepOut();
}
catch (err) {Utils.internalServerError(err, res, log);}
}
开发者ID:nandai,项目名称:web-service-template,代码行数:57,代码来源:onLoginEmail.ts
示例4:
process.nextTick(() =>
{
const hashPassword = Utils.getHashPassword(email, password, Config.PASSWORD_SALT);
Email.verify(email, hashPassword, (_err, user) =>
{
req.ext.command = 'signup';
req.user = user;
Email.callback(req, res);
});
});
开发者ID:nandai,项目名称:web-service-template,代码行数:10,代码来源:onSignupEmail.ts
示例5: onChangePassword
export async function onChangePassword(req : express.Request, res : express.Response)
{
const log = slog.stepIn('SettingsApi', 'onChangePassword');
try
{
do
{
const locale = req.ext.locale;
const param : Request.ChangePassword = req.body;
const condition : Request.ChangePassword =
{
oldPassword: ['string', null, true] as any,
newPassword: ['string', null, true] as any,
confirm: ['string', null, true] as any
};
// log.d(JSON.stringify(param, null, 2));
if (Utils.existsParameters(param, condition) === false)
{
res.ext.badRequest(locale);
break;
}
// 検証
const session : Session = req.ext.session;
const result = await isChangePasswordValid(param, session.account_id, locale);
if (result.response.status !== Response.Status.OK)
{
res.json(result.response);
break;
}
// 更新
const {account} = result;
account.password = Utils.getHashPassword(account.email, param.newPassword, Config.PASSWORD_SALT);
await AccountAgent.update(account);
// 送信
const data : Response.ChangePassword =
{
status: Response.Status.OK,
message: {general:R.text(R.PASSWORD_CHANGED, locale)}
};
res.json(data);
}
while (false);
log.stepOut();
}
catch (err) {Utils.internalServerError(err, res, log);}
}
开发者ID:nandai,项目名称:web-service-template,代码行数:52,代码来源:onChangePassword.ts
示例6: onResetPassword
export async function onResetPassword(req : express.Request, res : express.Response)
{
const log = slog.stepIn('ResetApi', 'onResetPassword');
try
{
do
{
const locale = req.ext.locale;
const param : Request.ResetPassword = req.body;
const condition : Request.ResetPassword =
{
resetId: ['string', null, true] as any,
password: ['string', null, true] as any,
confirm: ['string', null, true] as any
};
if (Utils.existsParameters(param, condition) === false)
{
res.ext.badRequest(locale);
break;
}
// 検証
const account = await AccountAgent.findByResetId(param.resetId);
const result = isResetPasswordValid(param, account, locale);
if (result.response.status !== Response.Status.OK)
{
res.json(result.response);
break;
}
// 更新
account.password = Utils.getHashPassword(account.email, param.password, Config.PASSWORD_SALT);
account.reset_id = null;
account.two_factor_auth = null;
await AccountAgent.update(account);
// 送信
const data : Response.ResetPassword =
{
status: Response.Status.OK,
message: {general:R.text(R.PASSWORD_RESET, locale)}
};
res.json(data);
}
while (false);
log.stepOut();
}
catch (err) {Utils.internalServerError(err, res, log);}
}
开发者ID:nandai,项目名称:web-service-template,代码行数:51,代码来源:onResetPassword.ts
示例7: onChangeEmail
export async function onChangeEmail(req : express.Request, res : express.Response)
{
const log = slog.stepIn('SettingsApi', 'onChangeEmail');
try
{
do
{
const locale = req.ext.locale;
const param : Request.ChangeEmail = req.body;
const condition : Request.ChangeEmail =
{
changeId: ['string', null, true] as any,
password: ['string', null, true] as any
};
if (Utils.existsParameters(param, condition) === false)
{
res.ext.badRequest(locale);
break;
}
// 検証
const account = await AccountAgent.findByChangeId(param.changeId);
const result = await isChangeEmailValid(param, account, locale);
if (result.response.status !== Response.Status.OK)
{
res.json(result.response);
break;
}
// メールアドレス設定(変更)
account.email = account.change_email;
account.password = Utils.getHashPassword(account.email, param.password, Config.PASSWORD_SALT);
account.change_id = null;
account.change_email = null;
await AccountAgent.update(account);
const response : Response.ChangeEmail =
{
status: Response.Status.OK,
message: {general:R.text(R.EMAIL_CHANGED, locale)}
};
res.json(response);
}
while (false);
log.stepOut();
}
catch (err) {Utils.internalServerError(err, res, log);}
}
开发者ID:nandai,项目名称:web-service-template,代码行数:50,代码来源:onChangeEmail.ts
示例8: onJoin
export async function onJoin(req : express.Request, res : express.Response)
{
const log = slog.stepIn('SignupApi', 'onJoin');
try
{
do
{
const locale = req.ext.locale;
const param : Request.Join = req.body;
const condition : Request.Join =
{
inviteId: ['string', null, true] as any,
password: ['string', null, true] as any
};
if (Utils.existsParameters(param, condition) === false)
{
res.ext.badRequest(locale);
break;
}
// 検証
const account = await AccountAgent.findByInviteId(param.inviteId);
const result = await isJoinValid(param, account, locale);
if (result.response.status !== Response.Status.OK)
{
res.json(result.response);
break;
}
// 更新
account.password = Utils.getHashPassword(account.email, param.password, Config.PASSWORD_SALT);
account.signup_id = null;
account.invite_id = null;
await AccountAgent.update(account);
// 送信
const data : Response.Join =
{
status: Response.Status.OK,
message: {general:R.text(R.SIGNUP_COMPLETED, locale)}
};
res.json(data);
}
while (false);
log.stepOut();
}
catch (err) {Utils.internalServerError(err, res, log);}
}
开发者ID:nandai,项目名称:web-service-template,代码行数:50,代码来源:onJoin.ts
示例9: isChangeEmailValid
export async function isChangeEmailValid(param : Request.ChangeEmail, account : Account, locale : string) : Promise<ValidationResult>
{
const log = slog.stepIn('SettingsApi', 'isChangeEmailValid');
const response : Response.ChangeEmail = {status:Response.Status.OK, message:{}};
const {password} = param;
do
{
if (account === null)
{
// メールアドレス設定の確認画面でメールアドレスの設定を完了させた後、再度メールアドレスの設定を完了させようとした場合にここに到達する想定。
// 変更IDで該当するアカウントがないということが必ずしもメールアドレスの設定済みを意味するわけではないが、
// 第三者が直接このAPIをコールするなど、想定以外のケースでなければありえないので変更済みというメッセージでOK。
response.status = Response.Status.FAILED;
response.message.general = R.text(R.ALREADY_EMAIL_CHANGED, locale);
break;
}
// メールアドレス変更メールを送信してから確認までの間に同じメールアドレスが本登録される可能性があるため、
// メールアドレスの重複チェックを行う
const changeEmail = account.change_email;
const alreadyExistsAccount = await AccountAgent.findByProviderId('email', changeEmail);
if (alreadyExistsAccount !== null && alreadyExistsAccount.signup_id === null)
{
response.status = Response.Status.FAILED;
response.message.general = R.text(R.ALREADY_EXISTS_EMAIL, locale);
break;
}
// パスワードチェック
const hashPassword = Utils.getHashPassword(account.email, password, Config.PASSWORD_SALT);
if (hashPassword !== account.password)
{
response.status = Response.Status.FAILED;
response.message.password = R.text(R.INVALID_PASSWORD, locale);
}
}
while (false);
if (response.status !== Response.Status.OK) {
log.w(JSON.stringify(response, null, 2));
}
log.stepOut();
return {response};
}
开发者ID:nandai,项目名称:web-service-template,代码行数:48,代码来源:onChangeEmail.ts
注:本文中的server/libs/utils.getHashPassword函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论