trabajo-afectivo/db/migrate/20170924054554_weibo_oauth2.rb

67 lines
1.8 KiB
Ruby
Raw Normal View History

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
2017-09-29 14:26:43 +00:00
class WeiboOauth2 < ActiveRecord::Migration[4.2]
2017-09-26 14:41:55 +00:00
def up
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
2017-09-26 14:41:55 +00:00
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_weibo',
area: 'Security::ThirdPartyAuthentication',
2017-09-26 14:41:55 +00:00
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
2017-09-26 14:41:55 +00:00
form: [
{
display: '',
null: true,
name: 'auth_weibo',
tag: 'boolean',
2017-09-26 14:41:55 +00:00
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_weibo_credentials'],
title_i18n: ['Weibo'],
2017-09-26 14:41:55 +00:00
description_i18n: ['Weibo', 'Sina Weibo Open Portal', 'http://open.weibo.com'],
permission: ['admin.security'],
2017-09-26 14:41:55 +00:00
},
state: false,
frontend: true
2017-09-26 14:41:55 +00:00
)
Setting.create_if_not_exists(
title: 'Weibo App Credentials',
name: 'auth_weibo_credentials',
area: 'Security::ThirdPartyAuthentication::Weibo',
2017-09-26 14:41:55 +00:00
description: 'Enables user authentication via Sina Weibo.',
options: {
2017-09-26 14:41:55 +00:00
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
2017-09-26 14:41:55 +00:00
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
2017-09-26 14:41:55 +00:00
},
],
},
state: {},
2017-09-26 14:41:55 +00:00
preferences: {
permission: ['admin.security'],
},
frontend: false
2017-09-26 14:41:55 +00:00
)
end
end