コード例 #1
0
 def result_schedule(self, schedule, result: bool):
     try:
         ses = Ses(settings.SES_ADDRESS, settings.SES_ADDRESS)
         ses.send_schedule_result(schedule, self.address, result)
     except ClientError as e:
         return e.response["Error"]["Message"]
     else:
         return "SUCCESS."
コード例 #2
0
 def notify(self,
            message: NotificationDestinationModel.NotificationMessage):
     try:
         ses = Ses(settings.SES_ADDRESS, settings.SES_ADDRESS)
         ses.send_notify_mail(message, self.address)
     except ClientError as e:
         return e.response["Error"]["Message"]
     else:
         return "SUCCESS."
コード例 #3
0
ファイル: reset_password.py プロジェクト: ko-takahara/naruko
    def reset_password(self, user: UserModel):
        self.logger.info("START: reset password")
        # パスワード変更
        reset_password = user.reset_password()
        user.save()

        try:
            # メール送信
            self.logger.info("START: Send mail by SES.")
            self.logger.info("using address. {}".format(settings.SES_ADDRESS))
            ses = Ses(settings.SES_ADDRESS, settings.SES_ADDRESS)
            ses.send_password_reset_mail(user.email, reset_password)
            self.logger.info("END: Send mail by SES.")
        except ClientError as e:
            self.logger.exception(e)
            raise InvalidEmailException

        self.logger.info("END: reset password")
        return user
コード例 #4
0
    def create_tenant(self, request_user: UserModel, tenant: TenantModel,
                      user: UserModel):
        self.logger.info("START: create_tenant")

        # 作成できるロールを持つか
        if not request_user.can_control_tenant():
            raise InvalidRoleException(
                "request user can't create tenant. id:{}".format(
                    request_user.id))

        # テナント追加
        tenant.save()

        # スケジューラーを登録する
        scheduler = UserModel(
            email=tenant.email,
            name="SCHEDULER",
            tenant=tenant,
            role=RoleModel.objects.get(id=RoleModel.SCHEDULER_ID),
        )
        scheduler.reset_password()
        scheduler.save()

        # ユーザー追加
        user.tenant = tenant
        # ランダムパスワード設定
        password = user.reset_password()
        user.save()

        # 新規登録メール送信
        self.logger.info("sending sign up email...")
        self.logger.debug(
            "user_email: {}, user_name: {}, tenant_name: {}".format(
                user.email, user.name, tenant.tenant_name))
        ses = Ses(settings.SES_ADDRESS, settings.SES_ADDRESS)
        ses.send_signup_user(user.email, user.name, tenant.tenant_name,
                             password)
        self.logger.info("sending sign up email... : DONE")

        self.logger.info("END: create_tenant")

        return tenant, user