mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Add profile links.
This commit is contained in:
@ -12,11 +12,22 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import {trim} from "./Util";
|
||||
|
||||
export let authConfig = {
|
||||
serverUrl: "http://example.com", // your Casdoor URL, like the official one: https://door.casbin.com
|
||||
appName: "app-example", // your Casdoor application name, like: "app-built-in"
|
||||
organizationName: "org-example", // your Casdoor organization name, like: "built-in"
|
||||
}
|
||||
|
||||
export function initAuthWithConfig(config) {
|
||||
authConfig = config;
|
||||
}
|
||||
|
||||
export function getMyProfileUrl() {
|
||||
return `${trim(authConfig.serverUrl)}/account`
|
||||
}
|
||||
|
||||
export function getUserProfileUrl(userName) {
|
||||
return `${trim(authConfig.serverUrl)}/users/${authConfig.organizationName}/${userName}`;
|
||||
}
|
||||
|
@ -25,3 +25,20 @@ export function showMessage(type, text) {
|
||||
message.error(text);
|
||||
}
|
||||
}
|
||||
|
||||
export function trim(str, ch) {
|
||||
if (str === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let start = 0;
|
||||
let end = str.length;
|
||||
|
||||
while(start < end && str[start] === ch)
|
||||
++start;
|
||||
|
||||
while(end > start && str[end - 1] === ch)
|
||||
--end;
|
||||
|
||||
return (start > 0 || end < str.length) ? str.substring(start, end) : str;
|
||||
}
|
||||
|
Reference in New Issue
Block a user