Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Frontend
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
400
Merge Requests
66
CI / CD
Security & Compliance
Packages
Analytics
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Compare Revisions
13d96fd6e22698791dbd4663607400864d648bc8...6822f8c9ade4a68f1d21da381d2ec0d9278997b8
Source
6822f8c9ade4a68f1d21da381d2ec0d9278997b8
...
Target
13d96fd6e22698791dbd4663607400864d648bc8
Compare
Commits (2)
(fix): if not a valid domain then redirect to root
· 7531c85c
Mark Harding
authored
3 hours ago
7531c85c
Merge branch 'fix/redirect-non-pro-to-root' into 'master'
· 6822f8c9
Mark Harding
authored
2 hours ago
If not a valid domain then redirect to root See merge request
!780
6822f8c9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
11 deletions
+79
-11
server.ts
View file @
6822f8c9
...
...
@@ -120,13 +120,13 @@ const cache = () => {
(
isMobileOrTablet
()
?
'
/mobile
'
:
'
/desktop
'
);
const
exists
=
myCache
.
has
(
key
);
if
(
exists
)
{
console
.
log
(
`from cache:
${
key
}
`
);
const
cachedBody
=
myCache
.
get
(
key
);
res
.
send
(
cachedBody
);
return
;
}
else
{
res
.
sendResponse
=
res
.
send
;
res
.
send
=
body
=>
{
if
(
res
.
finished
)
return
;
myCache
.
set
(
key
,
body
);
res
.
sendResponse
(
body
);
};
...
...
This diff is collapsed.
src/app/app.browser.module.ts
View file @
6822f8c9
...
...
@@ -6,6 +6,10 @@ import { Minds } from './app.component';
import
*
as
PlotlyJS
from
'
plotly.js/dist/plotly-basic.min.js
'
;
import
{
PlotlyModule
}
from
'
angular-plotly.js
'
;
import
{
CookieModule
}
from
'
@gorniv/ngx-universal
'
;
import
{
RedirectService
,
BrowserRedirectService
,
}
from
'
./common/services/redirect.service
'
;
PlotlyModule
.
plotlyjs
=
PlotlyJS
;
...
...
@@ -15,6 +19,10 @@ PlotlyModule.plotlyjs = PlotlyJS;
providers
:
[
{
provide
:
'
ORIGIN_URL
'
,
useValue
:
location
.
origin
},
{
provide
:
'
QUERY_STRING
'
,
useValue
:
location
.
search
||
''
},
{
provide
:
RedirectService
,
useClass
:
BrowserRedirectService
,
},
],
})
export
class
AppBrowserModule
{}
This diff is collapsed.
src/app/app.server.module.ts
View file @
6822f8c9
...
...
@@ -9,6 +9,10 @@ import { MindsModule } from './app.module';
import
{
Minds
}
from
'
./app.component
'
;
import
{
PlotlyModule
}
from
'
angular-plotly.js
'
;
import
{
CookieService
,
CookieBackendService
}
from
'
@gorniv/ngx-universal
'
;
import
{
ServerRedirectService
,
RedirectService
,
}
from
'
./common/services/redirect.service
'
;
PlotlyModule
.
plotlyjs
=
{
plot
:
()
=>
{
...
...
@@ -38,6 +42,10 @@ export class ServerXhr implements XhrFactory {
provide
:
CookieService
,
useClass
:
CookieBackendService
,
},
{
provide
:
RedirectService
,
useClass
:
ServerRedirectService
,
},
],
bootstrap
:
[
Minds
],
})
...
...
This diff is collapsed.
src/app/common/common.module.ts
View file @
6822f8c9
...
...
@@ -144,6 +144,7 @@ import { MediaProxyService } from './services/media-proxy.service';
import
{
HorizontalFeedService
}
from
'
./services/horizontal-feed.service
'
;
import
{
FormInputCheckboxComponent
}
from
'
./components/forms/checkbox/checkbox.component
'
;
import
{
AttachmentPasteDirective
}
from
'
./directives/paste/attachment-paste.directive
'
;
import
{
RedirectService
}
from
'
./services/redirect.service
'
;
const
routes
:
Routes
=
[
{
...
...
@@ -432,9 +433,14 @@ const routes: Routes = [
},
{
provide
:
ConfigsService
,
useFactory
:
(
client
,
injector
)
=>
new
ConfigsService
(
client
,
injector
.
get
(
'
QUERY_STRING
'
)),
deps
:
[
Client
,
Injector
],
useFactory
:
(
client
,
injector
,
redirect
,
location
)
=>
new
ConfigsService
(
client
,
injector
.
get
(
'
QUERY_STRING
'
),
redirect
,
location
),
deps
:
[
Client
,
Injector
,
RedirectService
,
Location
],
},
{
provide
:
MetaService
,
...
...
This diff is collapsed.
src/app/common/services/configs.service.ts
View file @
6822f8c9
import
{
Client
}
from
'
../api/client.service
'
;
import
{
Injectable
,
Inject
,
Optional
}
from
'
@angular/core
'
;
import
{
BehaviorSubject
,
Observable
}
from
'
rxjs
'
;
import
{
map
,
tap
}
from
'
rxjs/operators
'
;
import
{
Injectable
,
Inject
,
Optional
,
Injector
}
from
'
@angular/core
'
;
import
{
RedirectService
}
from
'
./redirect.service
'
;
import
{
Location
}
from
'
@angular/common
'
;
@
Injectable
()
export
class
ConfigsService
{
...
...
@@ -9,7 +9,9 @@ export class ConfigsService {
constructor
(
private
client
:
Client
,
@
Inject
(
'
QUERY_STRING
'
)
private
queryString
:
string
@
Inject
(
'
QUERY_STRING
'
)
private
queryString
:
string
,
private
redirectService
:
RedirectService
,
private
location
:
Location
)
{}
async
loadFromRemote
()
{
...
...
@@ -17,6 +19,7 @@ export class ConfigsService {
this
.
configs
=
await
this
.
client
.
get
(
`api/v1/minds/config
${
this
.
queryString
}
`
);
this
.
redirectToRootIfInvalidDomain
();
}
catch
(
err
)
{
console
.
error
(
err
);
}
...
...
@@ -29,4 +32,17 @@ export class ConfigsService {
set
(
key
,
value
):
void
{
this
.
configs
[
key
]
=
value
;
}
/**
* Redirect to the root domain if we have an invalid domain response from configs
* @return void
*/
private
redirectToRootIfInvalidDomain
():
void
{
if
(
this
.
get
(
'
redirect_to_root_on_init
'
)
===
true
)
{
const
redirectTo
:
string
=
this
.
get
(
'
site_url
'
)
+
this
.
location
.
path
().
substr
(
1
);
this
.
redirectService
.
redirect
(
redirectTo
);
throw
`Invalid domain. Redirecting to
${
redirectTo
}
`
;
}
}
}
This diff is collapsed.
src/app/common/services/redirect.service.ts
0 → 100644
View file @
6822f8c9
import
{
Inject
,
Injectable
}
from
'
@angular/core
'
;
import
{
RESPONSE
}
from
'
@nguniversal/express-engine/tokens
'
;
export
class
RedirectService
{
public
redirect
(
url
:
string
):
void
{}
}
export
class
BrowserRedirectService
extends
RedirectService
{
redirect
(
url
:
string
):
void
{
window
.
location
.
href
=
url
;
}
}
export
class
ServerRedirectService
extends
RedirectService
{
constructor
(@
Inject
(
RESPONSE
)
private
res
)
{
super
();
}
redirect
(
url
:
string
,
permanent
:
boolean
=
false
):
void
{
const
code
=
permanent
?
301
:
302
;
this
.
res
.
redirect
(
code
,
url
);
this
.
res
.
end
();
}
}
This diff is collapsed.
src/app/services/providers.ts
View file @
6822f8c9
...
...
@@ -50,6 +50,7 @@ import { ConfigsService } from '../common/services/configs.service';
import
{
TransferHttpInterceptorService
}
from
'
./transfer-http-interceptor.service
'
;
import
{
CookieHttpInterceptorService
}
from
'
./api/cookie-http-interceptor.service
'
;
import
{
CookieService
}
from
'
../common/services/cookie.service
'
;
import
{
RedirectService
}
from
'
../common/services/redirect.service
'
;
export
const
MINDS_PROVIDERS
:
any
[]
=
[
SiteService
,
...
...
@@ -186,9 +187,14 @@ export const MINDS_PROVIDERS: any[] = [
},
{
provide
:
ConfigsService
,
useFactory
:
(
client
,
injector
)
=>
new
ConfigsService
(
client
,
injector
.
get
(
'
QUERY_STRING
'
)),
deps
:
[
Client
,
Injector
],
useFactory
:
(
client
,
injector
,
redirect
,
location
)
=>
new
ConfigsService
(
client
,
injector
.
get
(
'
QUERY_STRING
'
),
redirect
,
location
),
deps
:
[
Client
,
Injector
,
RedirectService
,
Location
],
},
{
provide
:
FeaturesService
,
...
...
This diff is collapsed.