Snippets

Created by Riccardo Sibani last modified
We want people to sign in with a SSO like methodology.

1. NEED TO HAVE A TOKEN (ft3) https://gist.github.com/killerstorm/63b9ee6cdf580ec9b56f812347d2ad8e

Basic structure of the token

Classes:

* Account
* Asset 
* Balance
* Payment_history(log)(account; asset; timestamp; delta: integer) // we can infer block_height from here, thanks to log keyword

Operations:

* transfer(from, to, amount) // here inside we add payment_history


2. THE CUSTOM APP OPERATIONS (E.G. THE FORUM)
Given this, the custom app module structure will be

Classes:

// assuming we have companion, otherwise we can wrap up the update of standard class and require the length of the table to be <= 0

* object {last_block_read: integer};
* User(key master_key; mut balance_on_chain);
* user_auth(key user, pubkey; auth_id: text, expiration); // expiration could be timestamp or blockheight


Operations:

* read_payment_history() // Read payment history, reads from payment_history class the new changes and update its table
	---| get all rows after last_block_read
	---| process each row
	------| create user if not exists
	------| update balance

* login(master_key, newKey, auth_id) // auth_id is an identification string of the device, ideally it can be hash(browser version + pubkey), but it can get better with stuff like https://github.com/Valve/fingerprintjs2 . This allow one user to use the forum from different devices.
	---| if user with master_key doesn't exists
	------| create new user with 0 balance
	---| if user_auth record exists
	------| require user_auth is not expired
	------| if expired
	---------| delete expired row
	---| else
	------| create a new user_auth with auth_id, newKey and expiration

	
	





Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.