Add profile links.

This commit is contained in:
Yang Luo
2021-02-14 22:49:06 +08:00
parent 65eee22099
commit 906fe9758e
2 changed files with 28 additions and 0 deletions

View File

@ -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}`;
}

View File

@ -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;
}