Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.1.1 #4

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
18e2eb4
Email UI updated
vrijraj Apr 24, 2020
0350ae3
Mail ui improved in btn
vrijraj Apr 24, 2020
5174e26
Email ui cheacks added
vrijraj Apr 24, 2020
11de28a
Add Mail Added
vrijraj Apr 24, 2020
b40356f
User Management and Email Page
vrijraj May 5, 2020
543e844
UserAuth Disabled
vrijraj May 6, 2020
9f77df5
User management updated
vrijraj May 6, 2020
a46b50c
Cloud Function improved and Usermanagement ui updated
vrijraj May 7, 2020
21b23b8
User profile page added
vrijraj May 7, 2020
872abd1
Edit user roles
agarwalbharat May 7, 2020
4492d02
add user dialog improved
agarwalbharat May 7, 2020
4c14147
localstorage removed
agarwalbharat May 7, 2020
a42df18
team role is fetched and drawer updated
agarwalbharat May 7, 2020
03b1148
user management completed with every member login
agarwalbharat May 7, 2020
a5ce3e0
change password and update profile
agarwalbharat May 7, 2020
57f8879
Service and UI Improved in Speaker, Team
vrijraj May 8, 2020
48fa4bd
addteam check updated
vrijraj May 8, 2020
754b0ca
Events Details added in team and speaker view
vrijraj May 8, 2020
ebdfcde
View speaker and Team Ui Optimize
vrijraj May 8, 2020
9b6f424
Toolbar updated
vrijraj May 9, 2020
e238329
drawer and toolbar updated (profile image menu improved)
agarwalbharat May 9, 2020
583b962
signout updated
agarwalbharat May 9, 2020
15cb8e5
database integrity maintained in team removal
agarwalbharat May 9, 2020
4fcf2d5
minor bug fixed
agarwalbharat May 9, 2020
c42d07c
first time app setup handled
agarwalbharat May 9, 2020
5a099d9
console.log removed and some checks for admin added
agarwalbharat May 9, 2020
0b4fedd
notification => Push Notifications and functions updated
agarwalbharat May 9, 2020
30c5a33
email template updated for user management
agarwalbharat May 9, 2020
4f99e08
index.js updated
agarwalbharat May 11, 2020
a7c8249
checks improved
agarwalbharat May 11, 2020
a8465df
Merge pull request #38 from gdg-x/dev
agarwalbharat May 11, 2020
441b271
Mobile UI added in User Management
vrijraj May 11, 2020
92c0266
Created by, created on, lastupdatedby and last upadteon added to team…
agarwalbharat May 11, 2020
d3fdab9
Created info, updated info displyed on pages
agarwalbharat May 11, 2020
6315d78
Merge branch 'dev' of https://github.com/gdg-x/aura-admin into dev
agarwalbharat May 11, 2020
02cb0b5
Partners activity log shown and add to db
agarwalbharat May 11, 2020
78e2c1a
Merge pull request #40 from gdg-x/dev
agarwalbharat May 11, 2020
6a89222
User Management added
vrijraj May 12, 2020
26d13af
Readme updated
vrijraj May 12, 2020
4d246dc
Toolbar updated
vrijraj May 13, 2020
dc09fb0
Merge branch 'master' of https://github.com/gdg-x/aura-admin
vrijraj May 13, 2020
bd2aecd
updated from the upstream
chtushar May 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 158 additions & 145 deletions .firebase/hosting.ZGlzdA.cache

Large diffs are not rendered by default.

20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The template is created by [GDG Jalandhar](https://meetup.com/GDG-Jalandhar/) te
| **SEO optimized** | index all content and get to the top in search results |
| **Easy in management** | Store all the data in Cloud Firestore |
| **Trigger Push Notification** | Trigger Push Notification to Aura Main |
| **User Management** | Role based Authentication for the Team |
| **Usability** | Any Tech Communities can use |


Expand All @@ -42,11 +43,16 @@ The template is created by [GDG Jalandhar](https://meetup.com/GDG-Jalandhar/) te
service cloud.firestore {
match /databases/{database}/documents {
match /apiEnd/{apiEndpoint}{
allow read, write : if true;
allow read, create : if true;
allow delete : if request.auth.uid != null;
allow update : if request.auth.uid != null;
allow list: if request.auth.uid != null;
}
match /{document=**} {
allow read : if true;
allow write : if request.auth.uid != null;
allow read : if true;
allow delete : if request.auth.uid != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userType == "Super Admin";
allow create : if request.auth.uid != null;
allow update : if request.auth.uid != null;
}
}
}
Expand All @@ -69,6 +75,12 @@ The template is created by [GDG Jalandhar](https://meetup.com/GDG-Jalandhar/) te
1. Click on Authentication in the left navigation.
1. Click on Sign-in method and enable Email/Password
- Create user with Email and Password
1. For Cloud Functions
- `npm install` for installing dependencies
- Goto src/functions and then in the terminal run this command
```js
firebase functions:config:set someservice.email="yourmail@gmail.com" someservice.password="yourpassword"
```
1. Run locally
`npm run serve`
1. When you are ready to build for production, use the following command -
Expand Down Expand Up @@ -123,6 +135,8 @@ The template is created by [GDG Jalandhar](https://meetup.com/GDG-Jalandhar/) te
```
1. In your terminal at the root directory of the project, build and deploy using the following command
- `firebase deploy`
1. [Google LessSecure App](https://myaccount.google.com/lesssecureapps) open this link and enable Less secure app access
Also Allow access to your Google account from this [url](https://accounts.google.com/b/0/DisplayUnlockCaptcha)
1. If the project is successfully deployed, you should be able to visit your domain as found, and see the Aura Admin Dashboard. In future, we’ll refer to this website as your Aura Admin Dashboard.


Expand Down
14 changes: 6 additions & 8 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"hosting": {
"site":"gdgnadmin",
"site": "gdgnadmin",
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [ {
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
} ]
}
]
}
}
1 change: 1 addition & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
6 changes: 6 additions & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

// modules
exports.team = require('./modules/team')
246 changes: 246 additions & 0 deletions functions/modules/team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const nodemailer = require('nodemailer');

const APP_NAME = 'Aura Admin';
const mailTransport = nodemailer.createTransport({
service: 'gmail',
auth: {
user: functions.config().someservice.email,
pass: functions.config().someservice.password
},
});

exports.addMessage = functions.https.onCall((data) => {
console.log(data)
return data.text + ' Vrijraj Singh'
});

exports.disabledAuth = functions.https.onCall((uid) => {
return admin.auth().updateUser(uid, {
disabled: true
}).then(async (userRecord) => {
try {
let updateUser = await admin.firestore().collection('users').doc(uid).update({
disabled: true
})
return {
success: true,
msg: `${userRecord.toJSON().email} is Disabled`
}
} catch (e) {
return {
success: false,
cc: 'Error while updating user collections',
msg: e
}
}
}).catch(e => {
return {
success: false,
cc: 'Error while disabling user auth',
msg: e
}
})
})

exports.enabledAuth = functions.https.onCall((uid) => {
return admin.auth().updateUser(uid, {
disabled: false
}).then(async (userRecord) => {
try {
let updateUser = await admin.firestore().collection('users').doc(uid).update({
disabled: false
})
return {
success: true,
msg: `${userRecord.toJSON().email} is Enabled`
}
} catch (e) {
return {
success: false,
cc: 'Error while updating user collections',
msg: e
}
}
}).catch(e => {
return {
success: false,
cc: 'Error while disabling user auth',
msg: e
}
})
})

exports.removeAuth = functions.https.onCall((data) => {
console.log(data)
const uid = data.uid
const name = data.name
const communityEmail = data.communityEmail
const communityName = data.communityName
let email = ''

admin.auth().getUser(uid)
.then(function (userRecord) {
console.log('Successfully fetched user data:', userRecord.toJSON());
email = userRecord.toJSON().email
})
.catch(function (error) {
console.log('Error fetching user data:', error);
});

return admin.auth().deleteUser(uid)
.then(() => {
console.log('Successfully deleted user');
return admin.firestore().collection('users').doc(uid).delete().then(async () => {
let maildata = await sendGoodbyeEmail(email, name, communityName, communityEmail);
return {
success: true,
mailstatus: maildata,
msg: 'Successfully deleted user'
}
})
})
.catch((error) => {
console.log('Error deleting user:', error);
return {
success: false,
msg: error
}
});
})

exports.createAuthUser = functions.https.onCall(async (data) => {
console.log(data)
const email = data.email
const password = generateP()
const name = data.name
const userType = data.userType
const communityEmail = data.communityEmail
const communityName = data.communityName
return admin.auth().createUser({
email: email,
password: password
})
.then((userRecord) => {
console.log('Successfully created new user:', userRecord.uid);
return admin.firestore().collection('users').doc(userRecord.uid).set({
uid: userRecord.uid,
userType: userType,
id: data.id,
disabled: false
}).then(async () => {
console.log('User Created with uid: ' + userRecord.uid)
let maildata = await sendWelcomeEmail(email, name, password, communityEmail, communityName);
return admin.firestore().collection('team').doc(data.id).update({
uid: userRecord.uid
}).then(() => {
return {
success: true,
emailstatus: maildata,
msg: 'Successfully created new user',
uid: userRecord.uid,
docid: data.id
}
}).catch(e => {
return {
success: false,
emailstatus: maildata,
msg: 'Problem while updating team data',
error: e
}
})
}).catch(e => {
return {
success: false,
msg: 'Error in Creating User : ' + e,
}
})

})
.catch((error) => {
console.log('Error creating new user:', error);
return {
success: false,
msg: 'Error in Creating User : ' + error,
}
});
})

async function sendWelcomeEmail(email, displayName, pass, communityEmail, communityName) {
const mailOptions = {
from: `${communityName} <${communityEmail}>`,
to: email,
};
mailOptions.subject = `Welcome to ${communityName}!`;
mailOptions.html = `
<p>Hey ${displayName || ''}!</p>
<p>Welcome to ${communityName}. I hope you will enjoy our service.</p>
<p>This email contains important account access information for your ${email} account.</p>
<p>This is your temporary password: <b>${pass}</b></p>
<p>Kindly Login into Admin panel or Contact Admin</p>
<br>
<p>If you have any questions, please contact ${communityEmail}</p>
<br>
<p>Regards</p>
<p>Team ${communityName}</p>
`;
try {
let data = await mailTransport.sendMail(mailOptions);
return {
success: true,
msg: `Mail Sent to ${email}`
}
} catch (e) {
console.log(e);
return {
success: false,
msg: `Error ${e}`
}
}

}

async function sendGoodbyeEmail(email, name, communityName, communityEmail) {
const mailOptions = {
from: `${communityName} <${communityEmail}>`,
to: email,
};
mailOptions.subject = `Bye! to ${communityName}!`;
mailOptions.html = `
<p>Hey ${name}!</p>
<p>Bye to ${communityName}. I hope you have enjoyed our service.</p>
<p>We confirm that we have deleted your ${communityName} account. </p>
<br>
<p>If you have any questions, please contact ${communityEmail}</p>
<br>
<p>Regards</p>
<p>Team ${communityName}</p>
`;
try {
let data = await mailTransport.sendMail(mailOptions);
return {
success: true,
msg: `Mail Sent to ${email}`
};
} catch (e) {
console.log(e);
return {
success: false,
msg: `Error ${e}`
};
}

}

function generateP() {
var pass = '';
var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz0123456789@#$';
for (let i = 1; i <= 8; i++) {
var char = Math.floor(Math.random() * str.length + 1);

pass += str.charAt(char);
}
return pass;
}
Loading