MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / auth

Method auth

panel/src/app/entity/remote_service.ts:89–108  ·  view source on GitHub ↗
(key?: string)

Source from the content-addressed store, hash-verified

87 // This function will be executed automatically after the connection event is triggered.
88 // Generally, there is no need to execute it manually.
89 public async auth(key?: string) {
90 if (key) this.config.apiKey = key;
91 const daemonInfo = this.getDaemonInfo();
92 try {
93 const res = await new RemoteRequest(this).request("auth", this.config.apiKey, 5000, true);
94 if (res === true) {
95 this.available = true;
96 await this.setLanguage();
97 logger.info($t("TXT_CODE_daemonInfo.authSuccess", { v: daemonInfo }));
98 return true;
99 }
100 this.available = false;
101 logger.warn($t("TXT_CODE_daemonInfo.authFailure", { v: daemonInfo }));
102 return false;
103 } catch (error: any) {
104 logger.warn($t("TXT_CODE_daemonInfo.authError", { v: daemonInfo }));
105 logger.warn(error);
106 return false;
107 }
108 }
109
110 public emit(event: string, data?: any) {
111 return this.socket?.emit(event, data);

Callers 1

onConnectMethod · 0.95

Calls 5

getDaemonInfoMethod · 0.95
setLanguageMethod · 0.95
$tFunction · 0.90
requestMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected