Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit dee887c

Browse files
committed
feat: oobe
1 parent 9c98055 commit dee887c

File tree

13 files changed

+263
-47
lines changed

13 files changed

+263
-47
lines changed

ClassIsland.ManagementServer.Server/Controllers/Identity/UsersController.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using ClassIsland.ManagementServer.Server.Extensions;
55
using ClassIsland.ManagementServer.Server.Models;
66
using ClassIsland.ManagementServer.Server.Models.Identity;
7+
using ClassIsland.ManagementServer.Server.Services;
78
using Microsoft.AspNetCore.Authorization;
89
using Microsoft.AspNetCore.Identity;
910
using Microsoft.AspNetCore.Identity.Data;
@@ -17,11 +18,13 @@ namespace ClassIsland.ManagementServer.Server.Controllers.Identity;
1718
[Route("api/v1/users")]
1819
public class UsersController(ILogger<UsersController> logger,
1920
UserManager<User> userManager,
20-
ManagementServerContext dbContext) : ControllerBase
21+
ManagementServerContext dbContext,
22+
OrganizationSettingsService organizationSettingsService) : ControllerBase
2123
{
2224
public ILogger<UsersController> Logger { get; } = logger;
2325
public UserManager<User> UserManager { get; } = userManager;
2426
public ManagementServerContext DbContext { get; } = dbContext;
27+
public OrganizationSettingsService OrganizationSettingsService { get; } = organizationSettingsService;
2528

2629
[HttpPost("create")]
2730
[Authorize(Roles = Roles.UsersManager)]
@@ -164,6 +167,8 @@ private async Task<UserInfo> GetUserInfoFromUser(User user)
164167
CreatedTime = user.CreatedTime,
165168
UpdatedTime = user.UpdatedTime,
166169
Roles = (await UserManager.GetRolesAsync(user)).ToList(),
170+
RedirectToOobe = await OrganizationSettingsService.GetSettings("IsOobeCompleted") != "true"
171+
&& await UserManager.IsInRoleAsync(user, Roles.Admin)
167172
};
168173
}
169174

ClassIsland.ManagementServer.Server/Controllers/OrganizationSettingsController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ public async Task<IActionResult> UpdateBasicSettings([FromBody] BasicSettings bo
7474

7575
return Ok();
7676
}
77+
78+
[HttpPost("complete-oobe")]
79+
public async Task<IActionResult> CompleteOobe()
80+
{
81+
await OrganizationSettingsService.SetOrganizationSettings("IsOobeCompleted", "Oobe", "true");
82+
await DbContext.SaveChangesAsync();
83+
return Ok();
84+
}
7785
}

ClassIsland.ManagementServer.Server/Models/Identity/UserInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class UserInfo : IObjectWithTime
1818

1919
public List<string> Roles { get; set; } = [];
2020

21+
public bool RedirectToOobe { get; set; } = false;
22+
2123
public DateTime CreatedTime { get; set; } = DateTime.Now;
2224
public DateTime UpdatedTime { get; set; } = DateTime.Now;
2325
}

classisland.managementserver.client/src/api/apiDefinitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default {
6464
'clientregistry.put_api_v1_clients_registry_abstract': ['PUT', '/api/v1/clients_registry/abstract'],
6565
'clientregistry.put_api_v1_clients_registry_abstract_id': ['PUT', '/api/v1/clients_registry/abstract/{id}'],
6666
'clientregistry.delete_api_v1_clients_registry_abstract_id': ['DELETE', '/api/v1/clients_registry/abstract/{id}'],
67-
'clientregistry.post_api_v1_clients_registry_register': ['POST', '/api/v1/clients_registry/register'],
6867
'clientregistry.delete_api_v1_clients_registry_unregister': ['DELETE', '/api/v1/clients_registry/unregister'],
6968
'clientregistry.get_api_v1_clients_registry_query_cuid': ['GET', '/api/v1/clients_registry/query/{cuid}'],
7069
'clientregistry.get_api_v1_clients_registry_client_configure': ['GET', '/api/v1/clients_registry/client_configure'],
@@ -78,6 +77,7 @@ export default {
7877
'organizationsettings.post_api_v1_settings_brand': ['POST', '/api/v1/settings/brand'],
7978
'organizationsettings.get_api_v1_settings_basic': ['GET', '/api/v1/settings/basic'],
8079
'organizationsettings.post_api_v1_settings_basic': ['POST', '/api/v1/settings/basic'],
80+
'organizationsettings.post_api_v1_settings_complete_oobe': ['POST', '/api/v1/settings/complete-oobe'],
8181
'policies.get_api_v1_policies': ['GET', '/api/v1/policies'],
8282
'policies.post_api_v1_policies': ['POST', '/api/v1/policies'],
8383
'policies.get_api_v1_policies_id': ['GET', '/api/v1/policies/{id}'],

classisland.managementserver.client/src/api/globals.d.ts

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ export type User = {
378378
lockoutEnabled?: boolean;
379379
accessFailedCount?: number;
380380
name?: string | null;
381+
allowChangePassword?: boolean;
381382
createdTime?: string;
382383
updatedTime?: string;
383384
};
@@ -390,6 +391,12 @@ export type UserInfo = {
390391
name?: string | null;
391392
emailAddress?: string | null;
392393
phoneNumber?: string | null;
394+
id?: string | null;
395+
allowChangePassword?: boolean;
396+
roles?: string[] | null;
397+
redirectToOobe?: boolean;
398+
createdTime?: string;
399+
updatedTime?: string;
393400
};
394401
export type ChangePasswordRequestBody = {
395402
oldPassword?: string | null;
@@ -1864,40 +1871,6 @@ declare global {
18641871
>(
18651872
config: Config
18661873
): Alova2Method<unknown, 'clientregistry.delete_api_v1_clients_registry_abstract_id', Config>;
1867-
/**
1868-
* ---
1869-
*
1870-
* [POST]
1871-
*
1872-
* **path:** /api/v1/clients_registry/register
1873-
*
1874-
* ---
1875-
*
1876-
* **Query Parameters**
1877-
* ```ts
1878-
* type QueryParameters = {
1879-
* cuid?: string
1880-
* id?: string
1881-
* }
1882-
* ```
1883-
*
1884-
* ---
1885-
*
1886-
* **Response**
1887-
* ```ts
1888-
* type Response = unknown
1889-
* ```
1890-
*/
1891-
post_api_v1_clients_registry_register<
1892-
Config extends Alova2MethodConfig<unknown> & {
1893-
params: {
1894-
cuid?: string;
1895-
id?: string;
1896-
};
1897-
}
1898-
>(
1899-
config: Config
1900-
): Alova2Method<unknown, 'clientregistry.post_api_v1_clients_registry_register', Config>;
19011874
/**
19021875
* ---
19031876
*
@@ -2414,6 +2387,23 @@ declare global {
24142387
>(
24152388
config: Config
24162389
): Alova2Method<unknown, 'organizationsettings.post_api_v1_settings_basic', Config>;
2390+
/**
2391+
* ---
2392+
*
2393+
* [POST]
2394+
*
2395+
* **path:** /api/v1/settings/complete-oobe
2396+
*
2397+
* ---
2398+
*
2399+
* **Response**
2400+
* ```ts
2401+
* type Response = unknown
2402+
* ```
2403+
*/
2404+
post_api_v1_settings_complete_oobe<Config extends Alova2MethodConfig<unknown>>(
2405+
config?: Config
2406+
): Alova2Method<unknown, 'organizationsettings.post_api_v1_settings_complete_oobe', Config>;
24172407
};
24182408
policies: {
24192409
/**
@@ -3413,6 +3403,7 @@ declare global {
34133403
* lockoutEnabled?: boolean
34143404
* accessFailedCount?: number
34153405
* name?: string | null
3406+
* allowChangePassword?: boolean
34163407
* createdTime?: string
34173408
* updatedTime?: string
34183409
* }
@@ -3494,6 +3485,12 @@ declare global {
34943485
* name?: string | null
34953486
* emailAddress?: string | null
34963487
* phoneNumber?: string | null
3488+
* id?: string | null
3489+
* allowChangePassword?: boolean
3490+
* roles?: string[] | null
3491+
* redirectToOobe?: boolean
3492+
* createdTime?: string
3493+
* updatedTime?: string
34973494
* }
34983495
* ```
34993496
*
@@ -3633,6 +3630,12 @@ declare global {
36333630
* name?: string | null
36343631
* emailAddress?: string | null
36353632
* phoneNumber?: string | null
3633+
* id?: string | null
3634+
* allowChangePassword?: boolean
3635+
* roles?: string[] | null
3636+
* redirectToOobe?: boolean
3637+
* createdTime?: string
3638+
* updatedTime?: string
36363639
* }
36373640
* ```
36383641
*
212 KB
Loading

classisland.managementserver.client/src/router/guards.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export function createRouterGuards(router: Router) {
7272
router.addRoute(ErrorPageRoute as unknown as RouteRecordRaw);
7373
}
7474

75-
const redirectPath = (from.query.redirect || to.path) as string;
76-
const redirect = decodeURIComponent(redirectPath);
77-
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect };
75+
// const redirectPath = (from.query.redirect || to.path) as string;
76+
// const redirect = decodeURIComponent(redirectPath);
77+
const nextData = { ...to, replace: true };
7878
asyncRouteStore.setDynamicRouteAdded(true);
7979
next(nextData);
8080
Loading && Loading.finish();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { RouteRecordRaw } from 'vue-router';
2+
import { Layout } from '@/router/constant';
3+
import { LaptopOutlined } from '@vicons/antd';
4+
import { renderIcon } from '@/utils/index';
5+
6+
const routeName = 'get_started';
7+
8+
const routes: Array<RouteRecordRaw> = [
9+
{
10+
path: '/get_started',
11+
name: routeName,
12+
component: () => import('@/views/auth/AuthViewBase.vue'),
13+
meta: {
14+
title: '开始使用',
15+
hidden: true,
16+
roles: ["Admin"]
17+
},
18+
redirect: "/get_started/wizard",
19+
children: [
20+
{
21+
path: 'wizard',
22+
name: routeName + "_main",
23+
component: () => import('@/views/get_started/index.vue'),
24+
meta: {
25+
title: '开始使用',
26+
hidden: true,
27+
overrideDefaultAuthContainer: true,
28+
width: 540
29+
}
30+
},
31+
{
32+
path: 'completed',
33+
name: routeName + "_completed",
34+
component: () => import('@/views/get_started/completed.vue'),
35+
meta: {
36+
title: '完成',
37+
hidden: true,
38+
overrideDefaultAuthContainer: true,
39+
width: 540
40+
}
41+
}
42+
]
43+
}
44+
]
45+
46+
export default routes;

classisland.managementserver.client/src/store/modules/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type UserInfoType = {
1919
name: string;
2020
email: string;
2121
phoneNumber: string;
22+
redirectToOobe: bool;
2223
};
2324

2425
export interface IUserState {

classisland.managementserver.client/src/views/auth/AuthViewBase.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
import {websiteConfig} from "@/config/website.config";
44
import {useBrand} from "@/store/modules/brand";
55
import {computed, ref} from "vue";
6+
import {useRouter} from 'vue-router';
67
78
const brand = useBrand();
89
10+
const router = useRouter();
911
const bannerUrl = computed(() => {
1012
return "url(\"" + (brand.customLoginBanner ?? "") + "\")";
1113
});
1214
const bannerUrlRef = ref(bannerUrl);
1315
const isDefaultBackground = ref(brand.customLoginBanner == null || brand.customLoginBanner === "");
1416
const loginFormPlacement = ref<"left" | "center" | "right">(brand.loginFormPlacement ?? "left");
17+
const overrideDefaultAuthContainer = ref(router.currentRoute.value?.meta?.overrideDefaultAuthContainer === true);
18+
const contentWidth = ref(`${router.currentRoute.value?.meta?.width ?? 384}px`);
1519
1620
</script>
1721

@@ -23,8 +27,8 @@ const loginFormPlacement = ref<"left" | "center" | "right">(brand.loginFormPlace
2327
left: loginFormPlacement === 'left',
2428
center: loginFormPlacement === 'center',
2529
right: loginFormPlacement === 'right',
26-
}">
27-
<template #header>
30+
}" >
31+
<template #header v-if="!overrideDefaultAuthContainer">
2832
<div class="view-account-header">
2933
<img :src="websiteConfig.loginImage" alt="" width="36" height="36"
3034
class="align-middle"/>
@@ -50,8 +54,8 @@ const loginFormPlacement = ref<"left" | "center" | "right">(brand.loginFormPlace
5054
margin-top: 0;
5155
flex-grow: 0;
5256
align-self: center;
53-
max-width: 384px;
54-
min-width: 384px;
57+
max-width: v-bind(contentWidth);
58+
min-width: v-bind(contentWidth);
5559
@media (max-width: 640px) {
5660
border: none !important;
5761
align-self: stretch;

0 commit comments

Comments
 (0)