Add reset password & UI change

This commit is contained in:
Qolzam
2017-11-12 15:31:54 +07:00
parent 9ffd6a1e40
commit 55789967eb
22 changed files with 731 additions and 374 deletions

View File

@@ -12,6 +12,7 @@ try {
messagingSenderId: process.env.MESSAGING_SENDER_ID
}
console.log(firebase)
firebase.initializeApp(config)
} catch (error) {
console.log('=========Firebase initializer==============')

View File

@@ -108,8 +108,25 @@ export class AuthorizeService implements IAuthorizeService {
*
* @memberof IAuthorizeService
*/
onAuthStateChanged: (callBack: (user: User) => void) => any = (callBack) => {
public onAuthStateChanged: (callBack: (user: User) => void) => any = (callBack) => {
firebaseAuth().onAuthStateChanged(callBack)
}
/**
* Reset user password
*
* @memberof AuthorizeService
*/
public resetPassword: (email: string) => Promise<void> = (email) => {
return new Promise<void>((resolve,reject) => {
let auth = firebaseAuth()
auth.sendPasswordResetEmail(email).then(function () {
resolve()
}).catch((error: any) => {
// An error happened.
reject(new SocialError(error.code, error.message))
})
})
}
}

View File

@@ -18,7 +18,7 @@ export class CircleService implements ICircleService {
public addCircle: (userId: string, circle: Circle)
=> Promise<string> = (userId, circle) => {
return new Promise<string>((resolve,reject) => {
let circleRef = firebaseRef.child(`userCircles/${userId}/circles`).push(circle)
let circleRef = firebaseRef.child(`users/${userId}/circles`).push(circle)
circleRef.then(() => {
resolve(circleRef.key as string)
})
@@ -35,8 +35,8 @@ export class CircleService implements ICircleService {
return new Promise<void>((resolve,reject) => {
let updates: any = {}
updates[`userCircles/${userId}/circles/${circleId}/users/${userFollowingId}`] = userCircle
updates[`userCircles/${userFollowingId}/circles/-Followers/users/${userId}`] = userFollower
updates[`users/${userId}/circles/${circleId}/users/${userFollowingId}`] = userCircle
updates[`users/${userFollowingId}/circles/-Followers/users/${userId}`] = userFollower
firebaseRef.update(updates).then(() => {
resolve()
@@ -52,8 +52,8 @@ export class CircleService implements ICircleService {
return new Promise<void>((resolve,reject) => {
let updates: any = {}
updates[`userCircles/${userId}/circles/${circleId}/users/${userFollowingId}`] = null
updates[`userCircles/${userFollowingId}/circles/-Followers/users/${userId}`] = null
updates[`users/${userId}/circles/${circleId}/users/${userFollowingId}`] = null
updates[`users/${userFollowingId}/circles/-Followers/users/${userId}`] = null
firebaseRef.update(updates).then(() => {
resolve()
@@ -69,7 +69,7 @@ export class CircleService implements ICircleService {
return new Promise<void>((resolve,reject) => {
let updates: any = {}
updates[`userCircles/${userId}/circles/${circleId}`] = circle
updates[`users/${userId}/circles/${circleId}`] = circle
firebaseRef.update(updates).then(() => {
resolve()
})
@@ -85,7 +85,7 @@ export class CircleService implements ICircleService {
return new Promise<void>((resolve,reject) => {
let updates: any = {}
updates[`userCircles/${userId}/circles/${circleId}`] = null
updates[`users/${userId}/circles/${circleId}`] = null
firebaseRef.update(updates).then(() => {
resolve()
})
@@ -97,7 +97,7 @@ export class CircleService implements ICircleService {
}
public getCircles: (userId: string) => Promise<{ [circleId: string]: Circle }> = (userId) => {
return new Promise<{ [circleId: string]: Circle }>((resolve,reject) => {
let circlesRef: any = firebaseRef.child(`userCircles/${userId}/circles`)
let circlesRef: any = firebaseRef.child(`users/${userId}/circles`)
circlesRef.once('value').then((snapshot: any) => {
let circles: any = snapshot.val() || {}

View File

@@ -35,12 +35,12 @@ export class CommentService implements ICommentService {
})
}
public updateComment: (userId: string, postId: string, comment: Comment)
=> Promise<void> = (userId, postId, comment) => {
public updateComment: (commentId: string, postId: string, comment: Comment)
=> Promise<void> = (commentId, postId, comment) => {
return new Promise<void>((resolve,reject) => {
let updates: any = {}
updates[`postComments/${postId}/${userId}`] = comment
updates[`postComments/${postId}/${commentId}`] = comment
firebaseRef.update(updates)
.then(() => {
resolve()