-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from StorytellerCZ/feature/web3
Added freedombase:web3-login
- Loading branch information
Showing
9 changed files
with
148 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Meteor } from 'meteor/meteor' | ||
|
||
/** | ||
* | ||
* @param options.linkMessage { String } Message to display on wallet confirmation | ||
* @param callback { Function } | ||
*/ | ||
Meteor.linkWithWeb3 = function (options, callback) { | ||
if (!Meteor.userId()) { | ||
throw new Meteor.Error( | ||
402, | ||
'Please login to an existing account before link.' | ||
) | ||
} | ||
if (!Package['freedombase:web3-login']) { | ||
throw new Meteor.Error( | ||
403, | ||
'Please include freedombase:web3-login package.' | ||
) | ||
} | ||
|
||
if (!callback && typeof options === 'function') { | ||
callback = options | ||
options = null | ||
} | ||
|
||
// Since the flow for Web3 is different we are using a custom flow here. | ||
const credentialRequestCompleteCallback = (error, address) => { | ||
if (error.error === 403) { | ||
Meteor.call('bozhao:linkAccountsWeb3', address, callback) | ||
} else { | ||
throw error | ||
} | ||
} | ||
Package['freedombase:web3-login'].loginWithWeb3( | ||
options?.linkMessage || | ||
`Please verify that you want to link your wallet to ${Meteor.absoluteUrl()}.`, | ||
credentialRequestCompleteCallback | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters