Last active
August 29, 2015 14:25
-
-
Save dtzitz/d468fb4a9e37b2c0f085 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if (Meteor.isClient){ | |
console.log("subscribing to orgs") | |
Meteor.subscribe("orgs") | |
} | |
Template.organizations.events({ | |
'submit #newOrg':function(event){ | |
orgName = event.target.inputOrgName.value | |
orgAddress = event.target.inputAddress.value | |
orgSecAddress = event.target.inputSAddress.value | |
orgPOCemail = event.target.SecEmail.value | |
Meteor.call("addOrganization", orgName,orgAddress,orgSecAddress,orgPOCemail) | |
} | |
}) | |
Template.userAdmin.helpers({ | |
orgs: function(){ | |
return Orgs.find(); | |
} | |
}) | |
Template.userAdmin.events({ | |
'submit #newUser':function (event) { | |
userName = event.target.inputUserName.value | |
organization = event.target.organizations.value | |
userEmail = event.target.inputUserEmail.value | |
userPhone = event.target.inputUserPhone.value | |
console.log('this code is reached') | |
Meteor.call("addUser", userName,organization,userEmail,userPhone) | |
} | |
}) |
This file contains hidden or 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
Meteor.methods({ | |
addOrganization: function(orgName,orgAddress,orgSecAddress,orgPOCemail){ | |
//TO DO: authorization and authentication check | |
Orgs.insert({ | |
orgName:orgName, | |
orgAddress:orgAddress, | |
orgSecAddress:orgSecAddress, | |
orgPOCemail:orgPOCemail | |
}) | |
}, | |
debug:function(){ | |
console.log("debug from the server") | |
}, | |
addUser:function(userName,organization,userEmail,userPhone){ | |
//TO DO: authorization and authentication check | |
userOptions = { | |
email:userEmail, | |
profile: { | |
userName:userName, | |
organization:organization, | |
userPhone:userPhone, | |
}, | |
} | |
var userId= Accounts.createUser(userOptions); | |
Accounts.sendEnrollmentEmail(userId); | |
Meteor.users.insert(userId) | |
return userId; | |
//default role | |
//Roles.addUsersToRoles(id,[endUser]) | |
}, | |
}); | |
Meteor.publish("orgs", function(){ | |
//if user is not admin throw error not authoried | |
return Orgs.find() | |
}) |
This file contains hidden or 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
<template name="userAdmin"> | |
<div id="page-wrapper"> | |
<div class="container-fluid"> | |
<!-- Page Heading --> | |
<div class="row"> | |
<div class="col-lg-12"> | |
<h1 class="page-header"> | |
User Admin | |
</h1> | |
</div> | |
</div> | |
<!-- /.row --> | |
<div class="row"> | |
<div class="col-md-6 col-md-offset-2"> | |
<form id="newUser" class="form-horizontal"> | |
<div class="form-group"> | |
<label for="inputUserName" class="col-sm-4 control-label">User Name</label> | |
<div class="col-sm-8"> | |
<input type="text" id="inputUserName" class="form-control" placeholder="Lastname Firstname MI" > | |
</div> | |
</div> | |
<div class="form-group"> | |
<label for="organization" class="col-sm-4 control-label" >Organization</label> | |
<div class="col-sm-8"> | |
<input list="organizations" class="form-control" placeholder="Choose an organization from the list"> | |
<datalist id="organizations"> | |
{{#each orgs}} | |
<option value={{orgName}}></option> | |
{{/each}} | |
</datalist> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label for="inputUserEmail" class="col-sm-4 control-label">Email</label> | |
<div class="col-sm-8"> | |
<input type="email" name="inputUserEmail" class="form-control" placeholder="Users will be notified via email upon submission"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label for="inputUserPhone" class="col-sm-4 control-label">Commercial Phone</label> | |
<div class="col-sm-8"> | |
<input type="tel" name="inputUserPhone" class="form-control" pattern="^[0-9+\(\)#\.\s\/ext-]+$" placeholder="Please No DSN numbers"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-offset-4 col-sm-8"> | |
<button type="submit" id="newUser" class="btn btn-default">Submit</button> | |
</div> | |
</div> | |
</form> | |
</div> | |
</div> | |
</div> | |
<!-- /.container-fluid --> | |
</div> | |
<!-- /#page-wrapper --> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment