diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 91d5076b8..9e042ab3b 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -12,7 +12,7 @@ class Admin::UsersController < Admin::BaseController def create @user.role = params[:role] @user.confirmed_at = Time.now.utc - if @user.save + if (@user.save rescue false) flash[:notice] = t('flash.user.saved') redirect_to admin_users_path else diff --git a/lib/modules/models/personal_repository.rb b/lib/modules/models/personal_repository.rb index b821ce750..b5ca7bdb2 100644 --- a/lib/modules/models/personal_repository.rb +++ b/lib/modules/models/personal_repository.rb @@ -9,19 +9,25 @@ module Modules end def create_personal_repository - pl = own_platforms.build - pl.owner = self - pl.name = "#{self.uname}_personal" - pl.description = "#{self.uname}_personal" - pl.platform_type = 'personal' - pl.distrib_type = APP_CONFIG['distr_types'].first - pl.visibility = 'open' - pl.save! + begin + pl = own_platforms.build + pl.owner = self + pl.name = "#{self.uname}_personal" + pl.description = "#{self.uname}_personal" + pl.platform_type = 'personal' + pl.distrib_type = APP_CONFIG['distr_types'].first + pl.visibility = 'open' + pl.save! - rep = pl.repositories.build - rep.name = 'main' - rep.description = 'main' - rep.save! + rep = pl.repositories.build + rep.name = 'main' + rep.description = 'main' + rep.save! + rescue Exception => e + pl.now_destroy rescue false + raise e + end + return true end def personal_platform