Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPLOY 2025-01-21 #2079

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/helpers/account-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ export class AccountHandler {
* @param {function} refreshService - The function that refreshes the service.
* @return {string | object} The URL string or object to redirect to.
*/
async switchAccountFromSocialIdp(verifyService, refreshService) {
async switchAccountFromSocialIdp(verifyService, refreshService, EnableSocialLogin) {
try {
const { twoFactor, trustedDevice, user_tracking_info: userInfo } = await verifyService()

if (!userInfo) {
return '/login'
}

if (twoFactor) {
if (twoFactor && !EnableSocialLogin) {
const mfaRoute = trustedDevice ? 'authentication' : 'setup'
return `/mfa/${mfaRoute}`
}
Expand Down
7 changes: 6 additions & 1 deletion src/router/routes/switch-account-routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export const switchAccountRoutes = {
const refresh = AuthServices.refreshAuthenticationService

try {
const redirect = await accountHandler.switchAccountFromSocialIdp(verify, refresh)
const EnableSocialLogin = true
const redirect = await accountHandler.switchAccountFromSocialIdp(
verify,
refresh,
EnableSocialLogin
)
next(redirect)
} catch {
next({ name: 'login' })
Expand Down
13 changes: 11 additions & 2 deletions src/services/users-services/list-teams-service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { AxiosHttpClientAdapter, parseHttpResponse } from '../axios/AxiosHttpClientAdapter'
import { makeTeamsBaseUrl } from './make-teams-base-url'
import { InvalidDataStructureError } from '../axios/errors'
import { makeListServiceQueryParams } from '@/helpers/make-list-service-query-params'

export const listTeamsService = async ({
fields = '',
ordering = 'name',
page = 1,
pageSize = 100,
search = ''
} = {}) => {
const searchParams = makeListServiceQueryParams({ fields, ordering, page, pageSize, search })

export const listTeamsService = async () => {
let httpResponse = await AxiosHttpClientAdapter.request({
url: `${makeTeamsBaseUrl()}`,
url: `${makeTeamsBaseUrl()}?${searchParams.toString()}`,
method: 'GET'
})

Expand Down
3 changes: 2 additions & 1 deletion src/stores/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ export const useAccountStore = defineStore({
},
hasPermissionToEditDataStream(state) {
const permissionToEditDataStream = 'Edit Data Stream'
return !!state.account.permissions?.some(
const hasPermissionToEdit = !!state.account.permissions?.some(
(permission) => permission.name === permissionToEditDataStream
)
return hasPermissionToEdit || state.account.is_account_owner
},
hasPermissionToViewDataStream(state) {
return !!state.account.permissions.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('UsersServices', () => {
await sut()

expect(requestSpy).toHaveBeenCalledWith({
url: `${version}/iam/teams`,
url: `${version}/iam/teams?ordering=name&page=1&page_size=100&fields=&search=`,
method: 'GET'
})
})
Expand Down
9 changes: 5 additions & 4 deletions src/views/DataStream/EditView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
}
})

const store = useAccountStore()
const hasNoPermissionToEditDataStream = computed(() => store.hasPermissionToEditDataStream)
const hasAccessToSampling = computed(() => store.hasSamplingFlag)

// Schema de Validação
const validationSchema = yup.object({
name: yup.string().required(),
Expand All @@ -44,7 +48,7 @@
status: yup.boolean(),
hasSampling: yup.boolean(),
samplingPercentage: yup.number().when('hasSampling', {
is: true,
is: true && hasAccessToSampling.value,
then: (schema) =>
schema
.test('minmax', 'Sampling Percentage must be between 0 and 100', (value) => {
Expand Down Expand Up @@ -217,9 +221,6 @@
})
})

const store = useAccountStore()
const hasNoPermissionToEditDataStream = computed(() => store.hasPermissionToEditDataStream)

const displaySamplingDialog = ref(false)
const formSubmit = (onSubmit, values) => {
if (!values.hasSampling) {
Expand Down
2 changes: 2 additions & 0 deletions src/views/DataStream/FormFields/FormFieldsDataStream.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
<template #inputs>
<div class="flex flex-col w-full gap-8">
<FieldSwitchBlock
:disabled="hasNoPermissionToEditDataStream"
nameField="hasSampling"
name="hasSampling"
auto
Expand All @@ -193,6 +194,7 @@
v-if="hasSampling"
>
<FieldNumber
:disabled="hasNoPermissionToEditDataStream"
label="Sampling Percentage (%)"
name="samplingPercentage"
:value="samplingPercentage"
Expand Down
10 changes: 10 additions & 0 deletions src/views/DataStream/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
</template>
<template #content>
<div class="flex flex-col gap-3 items-start">
<InlineMessage
v-if="hasNoPermissionToCreateDataStream"
class="w-fit"
severity="info"
data-testid="permission-rule-message-data-stream"
>
This account has <strong>View Data Stream</strong> permission only. It allows viewing the
account’s streams but doesn't permit creating, editing, or deleting streams.
</InlineMessage>

<InlineMessage
v-if="isMaxDomainsReached"
severity="info"
Expand Down
8 changes: 5 additions & 3 deletions src/views/Users/FormsFields/FormFieldsUsers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
const { value: isAccountOwner } = useField('isAccountOwner')
const { value: teamsIds, errorMessage: errorTeamsIds } = useField('teamsIds')

const disabledUserTeams = computed(() => isAccountOwner.value || !optionsTeams.value.length)

const setCountriesOptions = (countries) => {
optionsCountriesMobile.value = countries
filteredCountriesMobile.value = [...countries]
Expand Down Expand Up @@ -145,12 +147,12 @@

const switchOptions = computed(() => [
{
title: 'Social login',
title: 'Account owner',
nameField: 'isAccountOwner',
readonly: accountIsOwner.value,
disabled: accountIsOwner.value,
subtitle:
'The Account Owner can enable or disable the Social Login functionality. When enabled, users linked to the account can authenticate on Azion using their social networks. When disabled, users must authenticate on Azion with their email and password.'
'Account owner: Full access to all features, including account and solution management. Non-owner: Restricted access to solution management, based on Teams permissions.'
},
{
title: 'Enforce Multi-Factor Authentication',
Expand Down Expand Up @@ -359,7 +361,7 @@
filter
autoFilterFocus
id="teams"
:disabled="isAccountOwner"
:disabled="disabledUserTeams"
:loading="!optionsTeams.length"
:options="optionsTeams"
optionLabel="label"
Expand Down
Loading