Skip to content

Commit

Permalink
Telegram: Better telegram response message on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdicarlo committed Apr 9, 2021
1 parent 3576798 commit 8c2045a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions electron-app/src/server/websites/telegram/telegram.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ export class Telegram extends Website {
phone_code: data.code,
phone_code_hash: this.authData[data.appId].phone_code_hash,
})
.then(() => true)
.then(() => {
result: true;
})
.catch((err) => {
this.logger.error(err);
return false;
return { result: false, message: err.error_message };
});
}

Expand Down
20 changes: 12 additions & 8 deletions ui/src/websites/telegram/TelegramLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class TelegramLogin extends React.Component<LoginDialogProps, Sta
extra={
<div>
<BrowserLink url="https://core.telegram.org/myapp">
You must create you own app configuration <Icon type="link" />
You must create your own app configuration <Icon type="link" />
</BrowserLink>
</div>
}
Expand Down Expand Up @@ -147,16 +147,20 @@ export default class TelegramLogin extends React.Component<LoginDialogProps, Sta
return;
}

WebsiteService.postCustomRoute<boolean>(this.props.account.website, 'authenticate', {
appId: this.state.appId,
code: this.state.code
})
.then(success => {
if (success) {
WebsiteService.postCustomRoute<{ result: boolean; message?: string }>(
this.props.account.website,
'authenticate',
{
appId: this.state.appId,
code: this.state.code
}
)
.then(res => {
if (res.result) {
message.success('Telegram authenticated.');
this.setState({ displayCodeDialog: false });
} else {
message.error('Failed to authenticate Telegram.');
message.error(res.message || 'Failed to authenticate Telegram.');
}
})
.catch(() => {
Expand Down

0 comments on commit 8c2045a

Please sign in to comment.