Skip to content

Commit 6bc2c3e

Browse files
authored
Merge pull request #94 from Coding-Club-IITG/prajit
calculate branch from rollno for btech
2 parents 0aff8c8 + 5725d0c commit 6bc2c3e

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

server/modules/auth/auth.controller.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,26 @@ export const fetchCoursesForBr = async (rollNumber) => {
174174
return courses;
175175
};
176176

177-
const getDepartment = async (access_token) => {
177+
const getDepartment = async (access_token, roll) => {
178+
let rollstring = roll.toString();
179+
const rollmap = {
180+
"06": "Biosciences and Bioengineering",
181+
"07": "Chemical Engineering",
182+
"22": "Chemical Science and Technology",
183+
"04": "Civil Engineering",
184+
"01": "Computer Science and Engineering",
185+
"50": "Data Science and Artificial Intelligence",
186+
"02": "Electronics and Communication Engineering",
187+
"08": "Electronics and Electrical Engineering",
188+
"51": "Energy Engineering",
189+
"21": "Engineering Physics",
190+
"23": "Mathematics and Computing",
191+
"03": "Mechanical Engineering",
192+
}
193+
if (rollstring.slice(2, 4) == "01" && rollstring.slice(4, 6) != "05") {
194+
const dep = rollmap[rollstring.slice(4,6)];
195+
if(dep) return rollmap[rollstring.slice(4, 6)];
196+
}
178197
var config = {
179198
method: "get",
180199
url: "https://graph.microsoft.com/beta/me/profile",
@@ -242,7 +261,7 @@ export const redirectHandler = async (req, res, next) => {
242261
let br = await BR.findOne({ email: userFromToken.data.mail });
243262
if (!existingUser) {
244263
//const courses = await fetchCourses(userFromToken.data.surname);
245-
const department = await getDepartment(AccessToken);
264+
const department = await getDepartment(AccessToken, roll);
246265
const previousCourses = [];
247266
//const previousCourses = await fetchCoursesForBr(userFromToken.data.surname);
248267
//const [courses,department,previousCourses]=await Promise.all([fetchCourses(userFromToken.data.surname),getDepartment(AccessToken),fetchCoursesForBr(userFromToken.data.surname)])

0 commit comments

Comments
 (0)