MOBILE-4059 core: Check supportavailability config
Config setting introduced in MDL-74643main
parent
fc55a31872
commit
c9120bce7b
|
@ -2749,10 +2749,21 @@ export type CoreSiteConfigResponse = {
|
||||||
warnings?: CoreWSExternalWarning[];
|
warnings?: CoreWSExternalWarning[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possible values for 'supportavailability' config.
|
||||||
|
*/
|
||||||
|
export const enum CoreSiteConfigSupportAvailability {
|
||||||
|
Disabled = 0,
|
||||||
|
Authenticated = 1,
|
||||||
|
Anyone = 2,
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Site config indexed by name.
|
* Site config indexed by name.
|
||||||
*/
|
*/
|
||||||
export type CoreSiteConfig = {[name: string]: string};
|
export type CoreSiteConfig = Record<string, string> & {
|
||||||
|
supportavailability?: string; // String representation of CoreSiteConfigSupportAvailability.
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result of WS tool_mobile_get_public_config.
|
* Result of WS tool_mobile_get_public_config.
|
||||||
|
@ -2784,6 +2795,7 @@ export type CoreSitePublicConfigResponse = {
|
||||||
agedigitalconsentverification?: boolean; // Whether age digital consent verification is enabled.
|
agedigitalconsentverification?: boolean; // Whether age digital consent verification is enabled.
|
||||||
supportname?: string; // Site support contact name (only if age verification is enabled).
|
supportname?: string; // Site support contact name (only if age verification is enabled).
|
||||||
supportemail?: string; // Site support contact email (only if age verification is enabled).
|
supportemail?: string; // Site support contact email (only if age verification is enabled).
|
||||||
|
supportavailability?: CoreSiteConfigSupportAvailability;
|
||||||
supportpage?: string; // Site support contact url.
|
supportpage?: string; // Site support contact url.
|
||||||
autolang?: number; // Whether to detect default language from browser setting.
|
autolang?: number; // Whether to detect default language from browser setting.
|
||||||
lang?: string; // Default language for the site.
|
lang?: string; // Default language for the site.
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
@auth @core_auth @app @javascript @lms_from4.0 @lms_upto4.0
|
||||||
|
Feature: Test basic usage of login in app
|
||||||
|
I need basic login functionality to work
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the following "users" exist:
|
||||||
|
| username | firstname | lastname |
|
||||||
|
| student1 | david | student |
|
||||||
|
|
||||||
|
Scenario: Forgot password
|
||||||
|
When I enter the app
|
||||||
|
And I press "Forgotten your username or password?" in the app
|
||||||
|
And I set the field "Enter either username or email address" to "student1"
|
||||||
|
And I press "Search" in the app
|
||||||
|
Then I should find "Success" in the app
|
||||||
|
|
||||||
|
When I press "OK" in the app
|
||||||
|
And I press "Forgotten your username or password?" in the app
|
||||||
|
Then I should find "Contact support" in the app
|
|
@ -135,8 +135,10 @@ Feature: Test basic usage of login in app
|
||||||
When I press "Reconnect" in the app
|
When I press "Reconnect" in the app
|
||||||
Then I should find "Acceptance test site" in the app
|
Then I should find "Acceptance test site" in the app
|
||||||
|
|
||||||
@lms_from4.0
|
@lms_from4.1
|
||||||
Scenario: Forgot password
|
Scenario: Forgot password
|
||||||
|
Given the following config values are set as admin:
|
||||||
|
| supportavailability | 2 |
|
||||||
When I enter the app
|
When I enter the app
|
||||||
And I press "Forgotten your username or password?" in the app
|
And I press "Forgotten your username or password?" in the app
|
||||||
And I set the field "Enter either username or email address" to "student1"
|
And I set the field "Enter either username or email address" to "student1"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { CoreSite } from '@classes/site';
|
import { CoreSite, CoreSiteConfigSupportAvailability } from '@classes/site';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreUserSupportConfig } from './support-config';
|
import { CoreUserSupportConfig } from './support-config';
|
||||||
|
|
||||||
|
@ -42,8 +42,28 @@ export class CoreUserAuthenticatedSupportConfig extends CoreUserSupportConfig {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
canContactSupport(): boolean {
|
canContactSupport(): boolean {
|
||||||
return this.site.isVersionGreaterEqualThan('4.0')
|
if (this.site.isFeatureDisabled('NoDelegate_CoreUserSupport')) {
|
||||||
&& !this.site.isFeatureDisabled('NoDelegate_CoreUserSupport');
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.site.isVersionGreaterEqualThan('4.1')) {
|
||||||
|
if (!this.site.config || !('supportavailability' in this.site.config)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const supportAvailability = Number(this.site.config.supportavailability);
|
||||||
|
|
||||||
|
return supportAvailability === CoreSiteConfigSupportAvailability.Authenticated
|
||||||
|
|| supportAvailability === CoreSiteConfigSupportAvailability.Anyone;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.site.isVersionGreaterEqualThan('4.0')) {
|
||||||
|
// This feature was always available in 4.0.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This feature wasn't available before 4.0.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { CoreSitePublicConfigResponse } from '@classes/site';
|
import { CoreSiteConfigSupportAvailability, CoreSitePublicConfigResponse } from '@classes/site';
|
||||||
import { CoreUserNullSupportConfig } from '@features/user/classes/support/null-support-config';
|
import { CoreUserNullSupportConfig } from '@features/user/classes/support/null-support-config';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -51,6 +51,12 @@ export class CoreUserGuestSupportConfig extends CoreUserSupportConfig {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
canContactSupport(): boolean {
|
canContactSupport(): boolean {
|
||||||
|
// This config was introduced in 4.1, if it's missing we can assume the site is 4.0 or lower.
|
||||||
|
if ('supportavailability' in this.config) {
|
||||||
|
return this.config.supportavailability === CoreSiteConfigSupportAvailability.Anyone;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This config is only available to guests since 4.0, if it's missing we can assume guests can't contact support.
|
||||||
return 'supportpage' in this.config;
|
return 'supportpage' in this.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ Feature: Site support
|
||||||
Given the following "users" exist:
|
Given the following "users" exist:
|
||||||
| username | firstname | lastname |
|
| username | firstname | lastname |
|
||||||
| student1 | Student | Student |
|
| student1 | Student | Student |
|
||||||
|
And I am logged in as "student1"
|
||||||
|
|
||||||
Scenario: Uses default support page
|
Scenario: Uses default support page
|
||||||
Given I entered the app as "student1"
|
Given I entered the app as "student1"
|
||||||
|
|
Loading…
Reference in New Issue