Advertisement
Guest User

Untitled

a guest
Mar 21st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. var fs = require("fs");
  2.  
  3. function Identity(id){
  4. this.id = id;
  5. }
  6.  
  7. Identity.prototype.serialize = function(){
  8. return {
  9. username: this.username,
  10. password: this.password,
  11. steamguard: this.steamguard,
  12. oauth: this.oauth,
  13. cookie: this.cookie,
  14. secrets: this.secrets,
  15. email: this.email
  16. };
  17. };
  18.  
  19. Identity.prototype.set = function(fields){
  20. this.username = fields.username || this.username;
  21. this.password = fields.password || this.password;
  22. this.steamguard = fields.steamguard || this.steamguard;
  23. this.oauth = fields.oauth || this.oauth;
  24. this.cookie = fields.cookie || this.cookie;
  25. this.secrets = fields.secrets || this.secrets;
  26. this.email = fields.email || this.email;
  27. }
  28.  
  29. Identity.prototype.load = function(callback){
  30. var self = this;
  31. fs.readFile(this.id, function(err, data) {
  32. if(!err){
  33. var fields = JSON.parse(data);
  34. self.set(fields);
  35. callback(false, fields);
  36. }else{
  37. callback("Can't load the identity");
  38. }
  39. });
  40. };
  41.  
  42. Identity.prototype.create = function(details, callback){
  43. this.set(details);
  44. this.update(callback);
  45. };
  46.  
  47. Identity.prototype.update = function(callback){;
  48. 2,0-1 Comienzo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement