@@ -39,8 +39,6 @@ module.exports.createToken = async function (req, res) {
3939
4040 //Check if the user exists in our db
4141 let user = await User . findOne ( { email : ghUserEmailResponse . data [ 0 ] . email } ) ;
42- // userBio acts both as a flag to see if it is a sign up and to get the user bio
43- let userBio = "" ;
4442 if ( ! user ) {
4543 //Create a new user if the user does not exist in our db
4644 const newUser = {
@@ -58,8 +56,6 @@ module.exports.createToken = async function (req, res) {
5856 newUser [ "name" ] = ghUserResponse . data . name || ghUserResponse . data . login ;
5957 newUser [ "username" ] = `${ ghUserResponse . data . login } _github` ;
6058 newUser [ "avatarUrl" ] = ghUserResponse . data . avatar_url ;
61- userBio = ghUserResponse . data . bio ;
62-
6359 /*
6460 In order to handle a case when user tries signing in gets created on RC but fails get stored in our db due to some error
6561 To keep it consistent with RC we store the (user-email,encrypted-rcPassword) pair in our fs so that it can be used
@@ -132,55 +128,6 @@ module.exports.createToken = async function (req, res) {
132128 }` ,
133129 } ) ;
134130
135- //Create a user community for newly signed up user
136- if ( userBio !== "" ) {
137- const headers = {
138- "X-Auth-Token" : rcLoginUserResponse . data . data . authToken ,
139- "X-User-Id" : rcLoginUserResponse . data . data . userId ,
140- "Content-type" : "application/json" ,
141- } ;
142-
143- //Create a user community on signup
144- const rcCreateChannelResponse = await axios ( {
145- method : "post" ,
146- url : `${ constants . rocketChatDomain } /api/v1/channels.create` ,
147- headers : headers ,
148- data : {
149- name : user . username . slice ( 0 , - 7 ) . concat ( "_community" ) ,
150- } ,
151- } ) ;
152-
153- await axios ( {
154- method : "post" ,
155- url : `${ constants . rocketChatDomain } /api/v1/channels.setTopic` ,
156- headers : headers ,
157- data : {
158- roomId : rcCreateChannelResponse . data . channel . _id ,
159- topic : `GitHub: https://github.com/${ user . username . slice ( 0 , - 7 ) } ` ,
160- } ,
161- } ) ;
162-
163- // User bio fetched from GitHub can either be null or a non-empty string
164- let description = ( userBio ? userBio : "" ) . concat ( `
165-
166- -----
167- Embed this channel
168- <pre><code><a href="${ constants . rc4gitDomain } /channel/${ user . username . slice ( 0 , - 7 ) . concat ( "_community" ) } ">
169- <img src="${ constants . rocketChatDomain } /images/join-chat.svg"/>
170- </a></code></pre>
171- ` ) ;
172-
173- await axios ( {
174- method : "post" ,
175- url : `${ constants . rocketChatDomain } /api/v1/channels.setDescription` ,
176- headers : headers ,
177- data : {
178- roomId : rcCreateChannelResponse . data . channel . _id ,
179- description : description ,
180- } ,
181- } ) ;
182- }
183-
184131 return res . status ( 200 ) . json ( {
185132 success : true ,
186133 data : {
0 commit comments