File tree Expand file tree Collapse file tree 4 files changed +28
-7
lines changed
src/Umbraco.Commerce.Checkout Expand file tree Collapse file tree 4 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,21 @@ export type InstallUccApiResponse = {
3
3
success : boolean ,
4
4
message ?: string
5
5
}
6
- export const installUmbracoCommerceCheckoutAsync : ( siteRootNodeId : string ) => Promise < InstallUccApiResponse > = ( siteRootNodeId : string ) => {
6
+
7
+ export const OpenApiConfig : {
8
+ credentials : RequestCredentials ,
9
+ token : ( ) => Promise < string > ,
10
+ } = {
11
+ credentials : 'same-origin' ,
12
+ token : async ( ) => '' ,
13
+ } ;
14
+
15
+ export const installUmbracoCommerceCheckoutAsync : ( siteRootNodeId : string ) => Promise < InstallUccApiResponse > = async ( siteRootNodeId : string ) => {
7
16
const response = fetch ( '/umbraco/management/api/v1/umbraco-commerce-checkout/install?siteRootNodeId=' + siteRootNodeId , {
8
- credentials : 'include' ,
17
+ credentials : OpenApiConfig . credentials ,
18
+ headers : {
19
+ 'Authorization' : 'Bearer ' + await OpenApiConfig . token ( ) ,
20
+ } ,
9
21
} ) . then (
10
22
( response : Response ) => {
11
23
return response . json ( ) as Promise < InstallUccApiResponse > ;
Original file line number Diff line number Diff line change 1
1
import type { UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api' ;
2
2
3
+ import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth' ;
3
4
import { manifests as dashboardManifest } from './dashboards/manifest' ;
4
-
5
5
import { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry' ;
6
+ import { OpenApiConfig } from './apis/install.api' ;
6
7
7
8
const manifests : Array < ManifestTypes > = [
8
9
...dashboardManifest ,
9
10
] ;
10
11
11
12
export const onInit : UmbEntryPointOnInit = ( _host , extensionRegistry ) => {
12
13
extensionRegistry . registerMany ( manifests ) ;
14
+ _host . consumeContext ( UMB_AUTH_CONTEXT , async ( instance ) => {
15
+ if ( ! instance ) return ;
16
+ const umbOpenApi = instance . getOpenApiConfiguration ( ) ;
17
+ OpenApiConfig . token = umbOpenApi . token ;
18
+ } ) ;
13
19
} ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Threading . Tasks ;
3
3
using Asp . Versioning ;
4
+ using Microsoft . AspNetCore . Authorization ;
4
5
using Microsoft . AspNetCore . Mvc ;
6
+ using Umbraco . Cms . Api . Management . Controllers ;
5
7
using Umbraco . Cms . Api . Management . Routing ;
6
8
using Umbraco . Cms . Core . Models ;
7
9
using Umbraco . Cms . Core . Services ;
10
+ using Umbraco . Cms . Web . Common . Authorization ;
8
11
using Umbraco . Commerce . Checkout . Services ;
9
12
using Umbraco . Commerce . Core . Api ;
10
13
using Umbraco . Commerce . Core . Models ;
11
14
12
15
namespace Umbraco . Commerce . Checkout . Web . Controllers
13
16
{
14
- [ ApiController ]
15
17
[ ApiVersion ( "1.0" ) ]
16
18
[ VersionedApiBackOfficeRoute ( "umbraco-commerce-checkout" ) ]
17
19
[ ApiExplorerSettings ( GroupName = "Umbraco Commerce Checkout API" ) ]
18
- //[Authorize(Policy = AuthorizationPolicies.SectionAccessSettings)]
19
- public class UmbracoCommerceCheckoutApiController : Controller
20
+ [ Authorize ]
21
+ [ Authorize ( AuthorizationPolicies . SectionAccessSettings ) ]
22
+ public class UmbracoCommerceCheckoutApiController : ManagementApiControllerBase
20
23
{
21
24
private readonly IUmbracoCommerceApi _commerceApi ;
22
25
private readonly IContentService _contentService ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"$schema" : " https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json" ,
3
- "version" : " 14.0.0-rc1 " ,
3
+ "version" : " 14.0.0-rc2 " ,
4
4
"assemblyVersion" : {
5
5
"precision" : " build"
6
6
},
You can’t perform that action at this time.
0 commit comments